		var AddSecondsCount = 0, AddSecondsText = 'Disabled', AddSec = 'false';
		var DebugOnOff = 0, DebugText = 'Disabled', DebugIt = false;
		var SortLists = true;
		var crewposted = 0;
		var BUBT = 6;
		var Bandit_type;
		var SecretDistrictCounter = 0;
		var ClickGo;
		var SkillPointAssinRunning = false;
		var ManualSpend = false;
		var SPAvaiable;
		var SkillsTo;
		var combinedEn2xp;
		var familyXPTypes = new Array("exp_fight", "exp_job", "exp_craft", "exp_social");
		var familyXPTypeStage = 0;
		var familyXPMastery = new Array("bronze", "silver", "gold", "ruby");
		var familyXPMasteryStage = 0;
		var BanditSkipperTimer;
		var HealOn;
/*start Arena Vars*/
	var ArenaReq;
	var ARS = false;
	var logs=[],
	looted = {},
	arena_running=false,
	mafia_attack = imgurl('icon_mafia_attack_22x16_01.gif','22','16','Mafia Attack Strength'),
	mafia_defense = imgurl('icon_mafia_defense_22x16_01.gif','22','16','Mafia Defense Strength'),
	starimg = '<img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/TeamVSTeam/result_star_filled.png" width="12" height="12" align="top" />',
	nostarimg = '<img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/TeamVSTeam/result_star_grey.png" width="12" height="12" align="top" />',
	socke, // websocket
	socke_lobby,
	currdata, // copy of data
	cmdqueue=[],
	meid, //me
	meteam, // my team
	tscore = {"1":0,"2":0},
	poweratt = undefined,
	poweruplist = {},
	playerinfo={},
	playerids={},
	starting_in,
	starting_in_counter,
	stam_on_start=-1,
	healed_in,
	healed_in_counter,
	itemdatabase={},
	worstitems,
	stats = { arenas:0,crests:0, xp:0, stamina:0, respect_start:0, respect:0, ranks:[0,0,0,0,0,0], stars:0, score:0},
	powerup_status = {},
	last_update = 0,
	update_debug=[],
	conn_checker,
    healtimer=[0,0,0,0,0,0],
	replenish=0,
	da_game = [],
	protect = {},
	powerup_command = { count:{},active:-1,target:undefined },
	show_config = false,
	over_table = false, //mouse hover over table -> no resort
	reconnect_retry = 0,
	arenalist=[],
	current_arena_was,
	last_crests = false;
	/*End Arena Vars*/
	
	var DroneX = {
			Version: '0.23',
			GrabCostCount: 0,
			JobMapCount: 0,
			StamMapCount: 0,
			JobMap: new Array(),
			StamMap: new Array(),
			SDMap: new Array(),
			SD: new Array(),
			EnergySelected: 0,
			StaminaSelected: 0,
			isRunning: true,
			isFirstLoad: true,
			CurrentLevel:$('#user_level').text(),
			LevelupPause:0,
			switchNRG: 0,
			slotsrobbed: 0,
			Imgs:{
				FamilyIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/family_icon_19x19pixels.png',
				EnergyIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon-energy.gif',
				StaminaIcon: 'http://mwfb.static.zynga.com/mwfb/graphics/icon_stamina_16x16_01.gif',
				ExpIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_experience_16x16_01.gif',
				RubyStar: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_star_16x16_ruby_01.gif',
				GoldStar: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_star_16x16_gold_01.gif',
				SilverStar: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_star_16x16_silver_01.gif',
				BronzeStar: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_star_16x16_bronze_01.gif',
				ChestKey: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/item_treasure_chest_key.gif',
				CashIcon: 'https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_cash_16x16_01.gif',
				AttackIcon: 'http://mwfb.static.zynga.com/mwfb/graphics/icon-attack.gif',
				DefenseIcon: 'http://mwfb.static.zynga.com/mwfb/graphics/icon-defense.gif',
				HealthIcon: 'http://mwfb.static.zynga.com/mwfb/graphics/icon-health.gif'
			},
			Bandits:{
				BanditGamblerXP: false,
				BanditGamblerCSH: false,
				BanditJob: false,
				lolzatcash: false,
				BanditElapsedTimerXP: 4,
				BanditElapsedTimerCash: 4,
				SkippyJOB: false,
				SkippyXP: false
			},
			Saving:{
				Restart: false,
				FamXP: false,
				AutoStart: false,
				AutopostingCrew: false,
				RemoveJobs: false,
				MarathonStat: false,
				StopAtLvl: false,
				Skippy: false,
				StopAtLvlNum: 0,
				RestartIn: 5,
				SkillSpending: 0,
				SkillToSpend: 'none',
				CrewAmount: 18,
				JobSpeed: 500,
				JobSpeedCounter: 2,
				PageLoadSpeed: 3000,
				PageLoadSpeedCounter: 3,
				StamFirst: 0,
				BanditCSHCheck: 4,
				BanditXPCheck: 1,
				BanditJOBCheck: 1,
				FightCityMenu: 0,
				IdleCityMenu: 0,
				FightCity: 1,
				IdleCity: 1,
				RobWhere: 0,
				LvlupCounter: 0,
				JobCounter: 0,
				mwId: '0',
				attackspeed: 888,
				Bursts: 1,
				HWP: false,
				BG: 0,
				ArenaCostMenu: 1,
				arenaSAO: false,
				arenaSA: true,
				arenaSAV: 5000,
				arenaPA: true,
				arenaNOA: 3,
				arenaSET: 0,
				arenaSS: true,
				arenaSSA: true,
				arenaBKS: 20,
				arenaBK: false,
				arenaSON: 0,
				arenaSOV: 0,
				arenaSP: false,
				arenaMF: false,
				isHiding: new Array()
			}
		};
		
		var NYJobMap = {
			/*D1:[
				{isName: "Perform a Hit (1.200)", isJobID: 37, isTab: 1, isCity: 1, isCost: 5, isTheXP: 6},
				{isName: "Grow Your Family (1.250)", isJobID: 8, isTab: 1, isCity: 1, isCost: 4, isTheXP: 5},
				{isName: "Collect Protection Money (1.333)", isJobID: 5, isTab: 1, isCity: 1, isCost: 3, isTheXP: 4},
				{isName: "Rob the Warehouse (1.000)", isJobID: 4, isTab: 1, isCity: 1, isCost: 3, isTheXP: 3},
				{isName: "Rough Up Dealers (1.000)", isJobID: 3, isTab: 1, isCity: 1, isCost: 3, isTheXP: 3},
				{isName: "Rob a Drug Runner (1.000)", isJobID: 2, isTab: 1, isCity: 1, isCost: 2, isTheXP: 2},
				{isName: "Chase Away Thugs (1.000)", isJobID: 1, isTab: 1, isCity: 1, isCost: 1, isTheXP: 1}
			],*/
			D2:[
				{isName: "Mugging (1.0000)", isJobID: 6, isTab: 2, isCity: 1},
				{isName: "Auto Theft (1.3333)", isJobID: 7, isTab: 2, isCity: 1},
				{isName: "Take Out a Rogue Cop (1.3333)", isJobID: 9, isTab: 2, isCity: 1},
				{isName: "Collect on a Loan (1.2500)", isJobID: 10, isTab: 2, isCity: 1},
				{isName: "Bank Heist (1.6667)", isJobID: 11, isTab: 2, isCity: 1},
				{isName: "Jewelry Store Job (1.7143)", isJobID: 12, isTab: 2, isCity: 1},
				{isName: "Hijack a Semi (1.7143)", isJobID: 38, isTab: 2, isCity: 1}
			],	
			D3:[
				{isName: "Destroy Enemy Mob Hideout (1.2000)", isJobID: 13, isTab: 3, isCity: 1},
				{isName: "Kill a Protected Snitch (1.2000)", isJobID: 14, isTab: 3, isCity: 1},
				{isName: "Bust a Made Man Out of Prison (1.2000)", isJobID: 15, isTab: 3, isCity: 1},
				{isName: "Asian Museum Break-in (1.3333)", isJobID: 16, isTab: 3, isCity: 1},
				{isName: "Fight a Haitian Gang (1.6000)", isJobID: 17, isTab: 3, isCity: 1},
				{isName: "Clip the Irish Mob's Local Enforcer (1.4444)", isJobID: 39, isTab: 3, isCity: 1},
				{isName: "Steal a Tanker Truck (1.2857)", isJobID: 40, isTab: 3, isCity: 1}
			],
			D4:[
				{isName: "Federal Reserve Raid (1.5909)", isJobID: 18, isTab: 4, isCity: 1},
				{isName: "Smuggle Thai Gems (1.5625)", isJobID: 19, isTab: 4, isCity: 1},
				{isName: "Liquor Smuggling (1.4815)", isJobID: 22, isTab: 4, isCity: 1},
				{isName: "Run Illegal Poker Game (2.1111)", isJobID: 26, isTab: 4, isCity: 1},
				{isName: "Wiretap the Cops (1.8889)", isJobID: 28, isTab: 4, isCity: 1},
				{isName: "Rob an Electronics Store (1.4286)", isJobID: 41, isTab: 4, isCity: 1},
				{isName: "Burn Down a Tenement (1.5625)", isJobID: 42, isTab: 4, isCity: 1},
				{isName: "Distill Some Liquor (1.5556)", isJobID: 23, isTab: 4, isCity: 1},
				{isName: "Manufacture Tokens (1.5556)", isJobID: 24, isTab: 4, isCity: 1},
				{isName: "Get Cheating Deck (1.5556)", isJobID: 25, isTab: 4, isCity: 1},
				{isName: "Overtake Phone Central (1.5556)", isJobID: 27, isTab: 4, isCity: 1}
			],
			D5:[
				{isName: "Repel the Yakuza (1.8182)", isJobID: 29, isTab: 5, isCity: 1},
				{isName: "Disrupt Rival Smuggling Ring (1.7692)", isJobID: 30, isTab: 5, isCity: 1},
				{isName: "Invade Tong-controlled Neighborhood (1.5909)", isJobID: 31, isTab: 5, isCity: 1},
				{isName: "Sell Guns to the Russian Mob (1.8182)", isJobID: 32, isTab: 5, isCity: 1},
				{isName: "Protect your City against a Rival Family (1.8710)", isJobID: 33, isTab: 5, isCity: 1},
				{isName: "Assassinate a Political Figure (1.8710)", isJobID: 34, isTab: 5, isCity: 1},
				{isName: "Exterminate a Rival Family (1.8611)", isJobID: 35, isTab: 5, isCity: 1},
				{isName: "Obtain Compromising Photos (1.4800)", isJobID: 43, isTab: 5, isCity: 1},
				{isName: "Frame a Rival Capo (1.6522)", isJobID: 44, isTab: 5, isCity: 1}
			],
			D6:[
				{isName: "Steal an Air Freight Delivery (1.4643)", isJobID: 45, isTab: 6, isCity: 1},
				{isName: "Run a Biker Gang Out of Town (1.4839)", isJobID: 46, isTab: 6, isCity: 1},
				{isName: "Flip a Snitch (1.5909)", isJobID: 47, isTab: 6, isCity: 1},
				{isName: "Steal Bank Records (1.5185)", isJobID: 48, isTab: 6, isCity: 1},
				{isName: "Loot the Police Impound Lot (1.2778)", isJobID: 49, isTab: 6, isCity: 1},
				{isName: "Recruit a Rival Crew Member (1.6667)", isJobID: 50, isTab: 6, isCity: 1},
				{isName: "Dodge an FBI Tail (1.6667)", isJobID: 51, isTab: 6, isCity: 1},
				{isName: "Whack a Rival Crew Leader (1.7600)", isJobID: 52, isTab: 6, isCity: 1}
			],
			D7:[
				{isName: "Influence a Harbor Official (1.6444)", isJobID: 53, isTab: 7, isCity: 1},
				{isName: "Move Stolen Merchandise (1.8125)", isJobID: 54, isTab: 7, isCity: 1},
				{isName: "Snuff a Rat (1.8205)", isJobID: 55, isTab: 7, isCity: 1},
				{isName: "Help a Fugitive Flee the Country (1.8333)", isJobID: 56, isTab: 7, isCity: 1},
				{isName: "Dispose of a Body (1.8636)", isJobID: 57, isTab: 7, isCity: 1},
				{isName: "Ransom a Businessman's Kids (1.5000)", isJobID: 58, isTab: 7, isCity: 1},
				{isName: "Fix the Big Game (1.5333)", isJobID: 59, isTab: 7, isCity: 1},
				{isName: "Steal an Arms Shipment (1.8750)", isJobID: 60, isTab: 7, isCity: 1}
			],
			D8:[
				{isName: "Extort a Corrupt Judge (1.9524)", isJobID: 61, isTab: 8, isCity: 1},
				{isName: "Embezzle Funds Through a Phony Company (1.8000)", isJobID: 62, isTab: 8, isCity: 1},
				{isName: "Break Into the Armory (1.5333)", isJobID: 63, isTab: 8, isCity: 1},
				{isName: "Rip Off the Armenian Mob (1.7333)", isJobID: 64, isTab: 8, isCity: 1},
				{isName: "Muscle in on a Triad Operation (1.9500)", isJobID: 65, isTab: 8, isCity: 1},
				{isName: "Ambush a Rival at a Sit Down (1.8776)", isJobID: 66, isTab: 8, isCity: 1},
				{isName: "Order a Hit on a Public Official (2.0323)", isJobID: 67, isTab: 8, isCity: 1},
				{isName: "Take Over an Identity Theft Ring (1.8750)", isJobID: 68, isTab: 8, isCity: 1}
			],
			D9:[
				{isName: "Settle a Beef... Permanently (1.9167)", isJobID: 69, isTab: 9, isCity: 1},
				{isName: "Buy Off a Federal Agent (2.1613)", isJobID: 70, isTab: 9, isCity: 1},
				{isName: "Make a Deal with the Mexican Cartel (1.9167)", isJobID: 71, isTab: 9, isCity: 1},
				{isName: "Blackmail the District Attorney (1.8974)", isJobID: 72, isTab: 9, isCity: 1},
				{isName: "Shake Down a City Council Member (2.0000)", isJobID: 73, isTab: 9, isCity: 1},
				{isName: "Make Arrangements for a Visiting Don (1.9167)", isJobID: 74, isTab: 9, isCity: 1},
				{isName: "Take Control of a Casino (1.9206)", isJobID: 75, isTab: 9, isCity: 1},
				{isName: "Travel to the Old Country (1.9565)", isJobID: 76, isTab: 9, isCity: 1}
			]
		};
		
		var BRLJobMap = {
			D1:[
				{isName: "Scope Out the Financial District (1.152)", isJobID: 1, isTab: 1, isCity: 7},
				{isName: "Set Up Your Operation in a Renovated Skyscraper (1.152)", isJobID: 2, isTab: 1, isCity: 7},
				{isName: "Ask an Informant About Local Crime Activity (1.163)", isJobID: 3, isTab: 1, isCity: 7},
				{isName: "Steal Artwork from the Paco Imperial (1.531)", isJobID: 4, isTab: 1, isCity: 7},
				{isName: "Bribe a Corporate Executive (1.152)", isJobID: 5, isTab: 1, isCity: 7},
				{isName: "Ambush a Group of Neo-Imperium (1.531)", isJobID: 6, isTab: 1, isCity: 7},
				{isName: "Destroy a Bondinho Tram (1.136)", isJobID: 7, isTab: 1, isCity: 7},
				{isName: "Blackmail a Cathedral Representative (1.146)", isJobID: 8, isTab: 1, isCity: 7},
				{isName: "Run a Collection Plate Con (1.378)", isJobID: 9, isTab: 1, isCity: 7},
				{isName: "Track Down Lieutenant Sandoval (1.598)", isJobID: 10, isTab: 1, isCity: 7},
				{isName: "Assassinate a Politician at a Museum Gala (1.47)", isJobID: 11, isTab: 1, isCity: 7}
			],
			D2:[
				{isName: "Meet a Contact at Mosqueiro (1.47)", isJobID: 13, isTab: 2, isCity: 7},
				{isName: "Impersonate a Wealthy Entrepreneur (1.47)", isJobID: 14, isTab: 2, isCity: 7},
				{isName: "Dispose of a Police Chief (1.705)", isJobID: 15, isTab: 2, isCity: 7},
				{isName: "Intimidate the Local Crime Ring (1.957)", isJobID: 16, isTab: 2, isCity: 7},
				{isName: "Track Down Neo-Imperium Members (1.705)", isJobID: 17, isTab: 2, isCity: 7},
				{isName: "Smuggle a Shipment Through Aeroporto de Belem (1.649)", isJobID: 18, isTab: 2, isCity: 7},
				{isName: "Steal the Plans (1.77)", isJobID: 19, isTab: 2, isCity: 7},
				{isName: "Burn Down a Jungle Hideout (1.899)", isJobID: 20, isTab: 2, isCity: 7},
				{isName: "Establish a Spy Ring of Belem Fishermen (1.818)", isJobID: 21, isTab: 2, isCity: 7},
				{isName: "Gun Down Kidnappers (2.027)", isJobID: 22, isTab: 2, isCity: 7},
				{isName: "Capture a Neo-Imperium Captain (1.862)", isJobID: 23, isTab: 2, isCity: 7},
				{isName: "Bribe a City Official (1.862)", isJobID: 24, isTab: 2, isCity: 7}
			],
			D3:[
				{isName: "Blackmail a City Official (1.7)", isJobID: 25, isTab: 3, isCity: 7},
				{isName: "Gather Intel from Street Rats (1.572)", isJobID: 26, isTab: 3, isCity: 7},
				{isName: "Assassinate a Neo-Imperium Spokesman (1.619)", isJobID: 27, isTab: 3, isCity: 7},
				{isName: "Bribe a Police Commandant (1.661)", isJobID: 28, isTab: 3, isCity: 7},
				{isName: "Pilfer from a Rebel Supply House (1.619)", isJobID: 29, isTab: 3, isCity: 7},
				{isName: "Locate a Rebel Outpost (1.665)", isJobID: 30, isTab: 3, isCity: 7},
				{isName: "Intercept a Rebel Convoy (1.742)", isJobID: 31, isTab: 3, isCity: 7},
				{isName: "Take Out a Rebel Lookout (1.631)", isJobID: 32, isTab: 3, isCity: 7},
				{isName: "Create a Diversion in the Jungle (1.67)", isJobID: 33, isTab: 3, isCity: 7},
				{isName: "Blow Up a Munitions Dump (1.602)", isJobID: 34, isTab: 3, isCity: 7},
				{isName: "Open Fire on Rebel Fighters (1.701)", isJobID: 35, isTab: 3, isCity: 7},
				{isName: "Rescue a Hostage (1.637)", isJobID: 36, isTab: 3, isCity: 7}
			],
			D4:[
				{isName: "Move to a Sao Paolo Safe House (1.702)", isJobID: 37, isTab: 4, isCity: 7},
				{isName: "Transport a Drug Shipment (1.731)", isJobID: 38, isTab: 4, isCity: 7},
				{isName: "Push Over a Gun Runner (1.827)", isJobID: 39, isTab: 4, isCity: 7},
				{isName: "Pass Along a Bribe (1.757)", isJobID: 40, isTab: 4, isCity: 7},
				{isName: "Contact a Comando do Candiru Agent (1.87)", isJobID: 41, isTab: 4, isCity: 7},
				{isName: "Scout Out the City (1.781)", isJobID: 42, isTab: 4, isCity: 7},
				{isName: "Rob a Jewelry Store (1.889)", isJobID: 43, isTab: 4, isCity: 7},
				{isName: "Burn Down a Slum Building (1.907)", isJobID: 44, isTab: 4, isCity: 7},
				{isName: "Escape a Police Pursuit (1.824)", isJobID: 45, isTab: 4, isCity: 7},
				{isName: "Demolish a Rooftop Helipad (1.855)", isJobID: 46, isTab: 4, isCity: 7},
				{isName: "Wipe Out a Favela Street Gang (1.873)", isJobID: 47, isTab: 4, isCity: 7},
				{isName: "Interrogate a Neo-Imperium Supporter (1.889)", isJobID: 48, isTab: 4, isCity: 7}
			],
			D5:[
				{isName: "Smuggle Weapons Down the River to a Recife Port (1.843)", isJobID: 49, isTab: 5, isCity: 7},
				{isName: "Negotiate a Sit-Down with the Comando do Candiru (1.813)", isJobID: 50, isTab: 5, isCity: 7},
				{isName: "Auction Off a Rival's Private Island (1.788)", isJobID: 51, isTab: 5, isCity: 7},
				{isName: "Detonate an Ethanol Shipment (1.859)", isJobID: 52, isTab: 5, isCity: 7},
				{isName: "Create a Shark Scare (1.832)", isJobID: 53, isTab: 5, isCity: 7},
				{isName: "Steal Confidential Medical Records (1.937)", isJobID: 54, isTab: 5, isCity: 7},
				{isName: "Blackmail a University Instructor (1.996)", isJobID: 55, isTab: 5, isCity: 7},
				{isName: "Raid a Biochemist's Lab (1.962)", isJobID: 56, isTab: 5, isCity: 7},
				{isName: "Sink a Cargo Ship in Port (1.764)", isJobID: 57, isTab: 5, isCity: 7},
				{isName: "Take Over a Shipyard (1.943)", isJobID: 58, isTab: 5, isCity: 7},
				{isName: "Give Chase to the Neo-Imperium (1.984)", isJobID: 59, isTab: 5, isCity: 7}
			],
			D6:[
				{isName: "Shake Down Some Locals For Information (2.006)", isJobID: 60, isTab: 6, isCity: 7},
				{isName: "Discover Connections to Local Gangs (2.021)", isJobID: 61, isTab: 6, isCity: 7},
				{isName: "Bribe a News Network Executive (2.061)", isJobID: 62, isTab: 6, isCity: 7},
				{isName: "Make an Announcement on a Local TV Network (1.905)", isJobID: 63, isTab: 6, isCity: 7},
				{isName: "Convince The Locals Of Your Good Intentions (2.01)", isJobID: 64, isTab: 6, isCity: 7},
				{isName: "Hunt Down The Revolucao Vermelho's Affiliates (1.937)", isJobID: 65, isTab: 6, isCity: 7},
				{isName: "Bust Up a Local Drug Ring (1.971)", isJobID: 66, isTab: 6, isCity: 7},
				{isName: "Delay a Police Patrol (2.04)", isJobID: 67, isTab: 6, isCity: 7},
				{isName: "Hijack a Fuel Truck (1.971)", isJobID: 68, isTab: 6, isCity: 7},
				{isName: "Offer Protection to a Franchise Business (1.996)", isJobID: 69, isTab: 6, isCity: 7},
				{isName: "Execute a Slum Gang Leader (2.086)", isJobID: 70, isTab: 6, isCity: 7},
				{isName: "Make a Direct Assault on the RV Base (2.099)", isJobID: 71, isTab: 6, isCity: 7}
			],
			D7:[
				{isName: "Mobilize Your Operation (2.006)", isJobID: 72, isTab: 7, isCity: 7},
				{isName: "Generate Revenue for Your Cause (2.079)", isJobID: 73, isTab: 7, isCity: 7},
				{isName: "Find Proof of Police Corruption (2.04)", isJobID: 74, isTab: 7, isCity: 7},
				{isName: "Rendezvous with Comando do Candiru Agents (2.079)", isJobID: 75, isTab: 7, isCity: 7},
				{isName: "Bribe a Carnival Director (2.079)", isJobID: 76, isTab: 7, isCity: 7},
				{isName: "Take Advantage of a Distracted Crowd (2.04)", isJobID: 77, isTab: 7, isCity: 7},
				{isName: "Blend in with a Group of Float Performers (2.015)", isJobID: 78, isTab: 7, isCity: 7},
				{isName: "Assassinate the Guest of Honor (2.058)", isJobID: 79, isTab: 7, isCity: 7},
				{isName: "Cut the RV's Purse Strings (2.006)", isJobID: 80, isTab: 7, isCity: 7},
				{isName: "Tail a Group of RV to Their Base (2.04)", isJobID: 81, isTab: 7, isCity: 7},
				{isName: "Remove the Police Protection (2.015)", isJobID: 82, isTab: 7, isCity: 7},
				{isName: "Demolish an RV stronghold (2.065)", isJobID: 83, isTab: 7, isCity: 7}
			],
			D8:[
				{isName: "Prepare an Ambush for a Neo-Imperium Sect (2.015)", isJobID: 84, isTab: 8, isCity: 7},
				{isName: "Interrogate Comando do Condiru Agents (2.05)", isJobID: 85, isTab: 8, isCity: 7},
				{isName: "Acquire Funds for Taubate Operations (2.086)", isJobID: 86, isTab: 8, isCity: 7},
				{isName: "Bribe a Taubate Prison Worker (2.221)", isJobID: 87, isTab: 8, isCity: 7},
				{isName: "Infiltrate Taubate Prison (2.05)", isJobID: 88, isTab: 8, isCity: 7},
				{isName: "Arrange for Prisoner Transfers (1.974)", isJobID: 89, isTab: 8, isCity: 7},
				{isName: "Disable Police Emergency Response (2.04)", isJobID: 90, isTab: 8, isCity: 7},
				{isName: "Cause Civilian Panic (2.099)", isJobID: 91, isTab: 8, isCity: 7},
				{isName: "Scout For Potential (2.065)", isJobID: 92, isTab: 8, isCity: 7},
				{isName: "Break Mafia Members Out of Taubate (2.024)", isJobID: 93, isTab: 8, isCity: 7},
				{isName: "Destroy the Neo-Imperium's Cover Operations (2.072)", isJobID: 94, isTab: 8, isCity: 7},
				{isName: "Assassinate the Neo-Imperium's Primary Heads (2.191)", isJobID: 95, isTab: 8, isCity: 7}
			]
		};

		var CHIJobMap = {
			D1:[
				{isName: "Meet With the South Gang Family (1.333)", isJobID: 1, isTab: 1, isCity: 8},
				{isName: "Drive North of the Border (1.333)", isJobID: 2, isTab: 1, isCity: 8},
				{isName: "Set Up a Rum Running Operation (1.25)", isJobID: 3, isTab: 1, isCity: 8},
				{isName: "Smuggle a Shipment Back to Chicago (1.75)", isJobID: 4, isTab: 1, isCity: 8},
				{isName: "Break Into Guido Pantucci's Warehouse (1.25)", isJobID: 5, isTab: 1, isCity: 8},
				{isName: "Dodge the Guards (1.75)", isJobID: 6, isTab: 1, isCity: 8},
				{isName: "Get Rid of Pantucci (1.167)", isJobID: 7, isTab: 1, isCity: 8},
				{isName: "Dispose of the Bodies (1.333)", isJobID: 8, isTab: 1, isCity: 8}
			],
			D2:[
				{isName: "Run an illegal Establishment (1.933)", isJobID: 9, isTab: 2, isCity: 8},
				{isName: "Secure Hooch to Sell in Your Joint (2.167)", isJobID: 10, isTab: 2, isCity: 8},
				{isName: "Recruit Loyal Gunmen (1.611)", isJobID: 11, isTab: 2, isCity: 8},
				{isName: "Case Warehouses on the North Side (2.143)", isJobID: 12, isTab: 2, isCity: 8},
				{isName: "Expose a Treachery in Your Family (1.625)", isJobID: 13, isTab: 2, isCity: 8},
				{isName: "Cripple the Colosimo Clan's Assets (1.926)", isJobID: 14, isTab: 2, isCity: 8},
				{isName: "Ambush the Don's Limo (1.939)", isJobID: 15, isTab: 2, isCity: 8},
				{isName: "Get the Respect You Deserve (1.972)", isJobID: 16, isTab: 2, isCity: 8}
			],
			D3:[ 
				{isName: "Move Smuggled Liquor (1.889)", isJobID: 17, isTab: 3, isCity: 8},
				{isName: "Collect Income From Your Establishments (1.974)", isJobID: 18, isTab: 3, isCity: 8},
				{isName: "Stuff Local Cop's Pockets With Greens (1.905)", isJobID: 19, isTab: 3, isCity: 8},
				{isName: "Organize a Private Party (1.926)", isJobID: 20, isTab: 3, isCity: 8},
				{isName: "Evade an Ambush (1.852)", isJobID: 21, isTab: 3, isCity: 8},
				{isName: "Uncover a Plot Against You (1.868)", isJobID: 22, isTab: 3, isCity: 8},
				{isName: "Order a Hit on Disloyal Associates (1.938)", isJobID: 23, isTab: 3, isCity: 8},
				{isName: "Put Brother Franky in Concrete Shoes (1.882)", isJobID: 24, isTab: 3, isCity: 8}
			],
			D4:[
				{isName: "Set Up a Distillery in Cicero (1.662)", isJobID: 25, isTab: 4, isCity: 8},
				{isName: "Meet With a Mayoral Candidate (1.734)", isJobID: 26, isTab: 4, isCity: 8},
				{isName: "Threaten Voters at Polling Stations (1.696)", isJobID: 27, isTab: 4, isCity: 8},
				{isName: "Get Puppet Mayor Elected (1.722)", isJobID: 28, isTab: 4, isCity: 8},
				{isName: "Escape a Federal Agents Raid on Your Distillery (1.711)", isJobID: 29, isTab: 4, isCity: 8},
				{isName: "Find Out About Mayor's Dealings With the Bureau (1.667)", isJobID: 30, isTab: 4, isCity: 8},
				{isName: "Blackmail a Prohibition Bureau Top Agent (1.824)", isJobID: 31, isTab: 4, isCity: 8},
				{isName: "Frame Mayor in a Political Scandal (1.867)", isJobID: 32, isTab: 4, isCity: 8}
			],
			D5:[ 
				{isName: "Travel South to the Caribbean (1.965)", isJobID: 33, isTab: 5, isCity: 8},
				{isName: "Set Up a Rum Running Base of Operation (1.84)", isJobID: 34, isTab: 5, isCity: 8},
				{isName: "Monitor Coast Guard Patrols (1.957)", isJobID: 35, isTab: 5, isCity: 8},
				{isName: "Hijack a Rival Ship (1.743)", isJobID: 36, isTab: 5, isCity: 8},
				{isName: "Eliminate the Competition (1.867)", isJobID: 37, isTab: 5, isCity: 8},
				{isName: "Comb the Beach for Scraps (1.831)", isJobID: 38, isTab: 5, isCity: 8},
				{isName: "Ferry Customers Across the Rum Line (1.965)", isJobID: 39, isTab: 5, isCity: 8},
				{isName: "Host Happy Hours on Board (1.939)", isJobID: 40, isTab: 5, isCity: 8}
			],
			D6:[
				{isName: "Catch a Saboteur (1.974)", isJobID: 41, isTab: 6, isCity: 8},
				{isName: "Storm Into a North Side Gang Brewery (2.078)", isJobID: 42, isTab: 6, isCity: 8},
				{isName: "Dodge a Firebombing on Your Headquarters (1.982)", isJobID: 43, isTab: 6, isCity: 8},
				{isName: "Salvage Your Valuables From a Blazing Fire (1.948)", isJobID: 44, isTab: 6, isCity: 8},
				{isName: "Call for a Truce With the North Siders (1.988)", isJobID: 45, isTab: 6, isCity: 8},
				{isName: "Narrowly Survive an Assassination Attempt (1.957)", isJobID: 46, isTab: 6, isCity: 8},
				{isName: "Plan a Decisive Blow Against the North Siders (1.988)", isJobID: 47, isTab: 6, isCity: 8},
				{isName: "Flee the Scene Before the Police Arrive (1.963)", isJobID: 48, isTab: 6, isCity: 8}
			]
		};
		
		var LONJobMap = {
			D1:[
				{isName: "Claim Your Winnings After The Match (1.281)", isJobID: 1, isTab: 1, isCity: 9},
				{isName: "Fight Off The Thugs (1.496)", isJobID: 2, isTab: 1, isCity: 9},
				{isName: "Discuss Your Options With The Betting Mafia (1.496)", isJobID: 3, isTab: 1, isCity: 9},
				{isName: "Persuade \"The Kid\" To Throw The Championship Fight (1.281)", isJobID: 4, isTab: 1, isCity: 9},
				{isName: "Spike \"The Kid's\" Energy Drink With A Neurotoxin (1.602)", isJobID: 5, isTab: 1, isCity: 9},
				{isName: "Bet On \"The Kid\" Losing The Championship Fight (1.423)", isJobID: 6, isTab: 1, isCity: 9},
				{isName: "Watch The Fight (1.373)", isJobID: 7, isTab: 1, isCity: 9},
				{isName: "Collect Your Take (1.707)", isJobID: 8, isTab: 1, isCity: 9}
			],
			D2:[
				{isName: "Force An Immigrant Family From Their Home (1.373)", isJobID: 9, isTab: 2, isCity: 9},
				{isName: "Meet The Land Mafia To Collect Your Take (1.707)", isJobID: 10, isTab: 2, isCity: 9},
				{isName: "Intimidate The New Celebrity Residents (1.602)", isJobID: 11, isTab: 2, isCity: 9},
				{isName: "Case The Nouvelle Vague Art Gallery (1.868)", isJobID: 12, isTab: 2, isCity: 9},
				{isName: "Destroy The Rare East End Works Painting (1.778)", isJobID: 13, isTab: 2, isCity: 9},
				{isName: "Burn Down A Brand New Condo (1.815)", isJobID: 14, isTab: 2, isCity: 9},
				{isName: "Collect Your Take From The Construction Firms (2.134)", isJobID: 15, isTab: 2, isCity: 9},
				{isName: "Leave The East End (1.957)", isJobID: 16, isTab: 2, isCity: 9}
			],
			D3:[ 
				{isName: "Write About The Mysterious Shooting (1.887)", isJobID: 17, isTab: 3, isCity: 9},
				{isName: "Work With The PI At The Crime Scene (1.829)", isJobID: 18, isTab: 3, isCity: 9},
				{isName: "Approach The Police With Leads (2.051)", isJobID: 19, isTab: 3, isCity: 9},
				{isName: "Search For A Trail (1.921)", isJobID: 20, isTab: 3, isCity: 9},
				{isName: "Threaten To Expose The Royal (1.849)", isJobID: 21, isTab: 3, isCity: 9},
				{isName: "Lay A Trap For The Royal (1.867)", isJobID: 22, isTab: 3, isCity: 9},
				{isName: "Tell The Editor The Truth (1.82)", isJobID: 23, isTab: 3, isCity: 9},
				{isName: "Publish False Story Under Threat (1.867)", isJobID: 24, isTab: 3, isCity: 9}
			],
			D4:[
				{isName: "Accept The Offer Made By The Russians (1.778)", isJobID: 25, isTab: 4, isCity: 9},
				{isName: "Provide Insider Information On Your Gang (2.074)", isJobID: 26, isTab: 4, isCity: 9},
				{isName: "Escape The Hitmen After Being Discovered (1.92)", isJobID: 27, isTab: 4, isCity: 9},
				{isName: "Take Shelter In A Warehouse (2.021)", isJobID: 28, isTab: 4, isCity: 9},
				{isName: "Fake Your Own Death (1.88)", isJobID: 29, isTab: 4, isCity: 9},
				{isName: "Create A Russian Identity (2.081)", isJobID: 30, isTab: 4, isCity: 9},
				{isName: "Eliminate Your Gang With The Russians (1.93)", isJobID: 31, isTab: 4, isCity: 9},
				{isName: "Run The Racket (1.981)", isJobID: 32, isTab: 4, isCity: 9}
			],
			D5:[ 
				{isName: "Sneak Into The Gambling Den (1.92)", isJobID: 33, isTab: 5, isCity: 9},
				{isName: "Gamble Away All Your Savings (1.93)", isJobID: 34, isTab: 5, isCity: 9},
				{isName: "Bargain To Push 'Power Ups' To Pay Off Your Debts (1.891)", isJobID: 35, isTab: 5, isCity: 9},
				{isName: "Sell 'Power Ups' At School (2.087)", isJobID: 36, isTab: 5, isCity: 9},
				{isName: "Start An Operation (1.981)", isJobID: 37, isTab: 5, isCity: 9},
				{isName: "Pay Off Your Debts (1.988)", isJobID: 38, isTab: 5, isCity: 9},
				{isName: "Run Your Empire (2.241)", isJobID: 39, isTab: 5, isCity: 9},
				{isName: "Join The Inner Circle (2.087)", isJobID: 40, isTab: 5, isCity: 9}
			],
			D6:[
				{isName: "Analyze Your Agent's Data (1.93)", isJobID: 41, isTab: 6, isCity: 9},
				{isName: "Organize A Raid On The Gang Hideout (1.891)", isJobID: 42, isTab: 6, isCity: 9},
				{isName: "Ambush The Convoy Transporting The Gang Boss (2.087)", isJobID: 43, isTab: 6, isCity: 9},
				{isName: "Drive The Gang Boss To A Safehouse (2.045)", isJobID: 44, isTab: 6, isCity: 9},
				{isName: "Forge The Reports (2.176)", isJobID: 45, isTab: 6, isCity: 9},
				{isName: "Observe Your Agent Snooping Around (2.083)", isJobID: 46, isTab: 6, isCity: 9},
				{isName: "Snipe Your Agent Before He Goes Public (1.929)", isJobID: 47, isTab: 6, isCity: 9},
				{isName: "Close The Investigation (2.048)", isJobID: 48, isTab: 6, isCity: 9}
			],
			D7:[
				{isName: "Track Down Your Target (2.134)", isJobID: 49, isTab: 7, isCity: 9},
				{isName: "Assassinate Your Target (2.027)", isJobID: 50, isTab: 7, isCity: 9},
				{isName: "Declare Your Retirement To The Boss (2)", isJobID: 51, isTab: 7, isCity: 9},
				{isName: "Chase Down Your Son's Kidnappers (2.231)", isJobID: 52, isTab: 7, isCity: 9},
				{isName: "Sneak Into The Manor (2.19)", isJobID: 53, isTab: 7, isCity: 9},
				{isName: "Rescue Your Son (1.92)", isJobID: 54, isTab: 7, isCity: 9},
				{isName: "Take Out The Boss And His Guards (2.037)", isJobID: 55, isTab: 7, isCity: 9},
				{isName: "Retire To The Isle Of Wight (2.226)", isJobID: 56, isTab: 7, isCity: 9}
			],
			D8:[
				{isName: "Meet Your Source (2.021)", isJobID: 57, isTab: 8, isCity: 9},
				{isName: "Investigate The Trail Of The Puzzle Box (2.252)", isJobID: 58, isTab: 8, isCity: 9},
				{isName: "Audition Your Potential Partners (2.045)", isJobID: 59, isTab: 8, isCity: 9},
				{isName: "Storm The Tower Of London (2.037)", isJobID: 60, isTab: 8, isCity: 9},
				{isName: "Steal The Puzzle Box (2.134)", isJobID: 61, isTab: 8, isCity: 9},
				{isName: "Fight Off The Police (2.279)", isJobID: 62, isTab: 8, isCity: 9},
				{isName: "Escape Into The Back Alleys (2.133)", isJobID: 63, isTab: 8, isCity: 9},
				{isName: "Open The Puzzle Box (1.969)", isJobID: 64, isTab: 8, isCity: 9}
			],
			D9:[
				{isName: "Set Up A Drug Racket From Your Kebab Shop (2.193)", isJobID: 65, isTab: 9, isCity: 9},
				{isName: "Expand The Business With Turkish Smugglers' Help (2.19)", isJobID: 66, isTab: 9, isCity: 9},
				{isName: "Reap The Benefits (2.226)", isJobID: 67, isTab: 9, isCity: 9},
				{isName: "Suspect Foul Play (2.187)", isJobID: 68, isTab: 9, isCity: 9},
				{isName: "Silence Your Disloyal Associates (2.134)", isJobID: 69, isTab: 9, isCity: 9},
				{isName: "Pretend To Be A Survivor (2.134)", isJobID: 70, isTab: 9, isCity: 9},
				{isName: "Get Compensation From Insurance Company (2.048)", isJobID: 71, isTab: 9, isCity: 9},
				{isName: "Open Various Branches Across London But Beware (2.051)", isJobID: 72, isTab: 9, isCity: 9}
			],
			D10:[
				{isName: "Queue Up At The Grande Stadium For The Game (2.134)", isJobID: 73, isTab: 10, isCity: 9},
				{isName: "Enjoy The Game At Rival Team's Cost (2.252)", isJobID: 74, isTab: 10, isCity: 9},
				{isName: "Go To A Pub To Celebrate Your Team's Win (2.231)", isJobID: 75, isTab: 10, isCity: 9},
				{isName: "Poke Your Team's Victory In Rival Fans' Faces (2.226)", isJobID: 76, isTab: 10, isCity: 9},
				{isName: "Defend Yourself From The Rival's Fans (2.231)", isJobID: 77, isTab: 10, isCity: 9},
				{isName: "Make A Run For It And Hide (2.187)", isJobID: 78, isTab: 10, isCity: 9},
				{isName: "Speak To Your Uncle With Connections (2.222)", isJobID: 79, isTab: 10, isCity: 9},
				{isName: "Make The Club Pay For Their Disrespect (2.226)", isJobID: 80, isTab: 10, isCity: 9}
			]
		};
		
		var SAJobMap = {
			D1:[
				{isName: "Help Out At The Shipwreck (1.754)", isJobID: 1, isTab: 1, isCity: 10},
				{isName: "Steal The Cargo Of Diamonds (1.945)", isJobID: 2, isTab: 1, isCity: 10},
				{isName: "Hunt For The Highest Bidder (1.98)", isJobID: 3, isTab: 1, isCity: 10},
				{isName: "Rally The Union To Join Your Operation (1.994)", isJobID: 4, isTab: 1, isCity: 10},
				{isName: "Hide Your Shipment (2.024)", isJobID: 5, isTab: 1, isCity: 10},
				{isName: "Discover A Rat In Your Operation (2.024)", isJobID: 6, isTab: 1, isCity: 10},
				{isName: "Hire The Mafia As Muscle (2.047)", isJobID: 7, isTab: 1, isCity: 10},
				{isName: "Protect Your Shipment Into International Waters (2.126)", isJobID: 8, isTab: 1, isCity: 10},
				{isName: "Join Forces With The Mafia (2.126)", isJobID: 9, isTab: 1, isCity: 10},
				{isName: "Set Up A Diamond Smuggling Racket (2.237)", isJobID: 10, isTab: 1, isCity: 10}
			],
			D2:[
				{isName: "Steal A Diamond At Work (1.822)", isJobID: 11, isTab: 2, isCity: 10},
				{isName: "Defend Yourself Against The Supervisors (1.949)", isJobID: 12, isTab: 2, isCity: 10},
				{isName: "Distract The Guards (2.024)", isJobID: 13, isTab: 2, isCity: 10},
				{isName: "Loot The Safe Of Diamonds (1.889)", isJobID: 14, isTab: 2, isCity: 10},
				{isName: "Locate The Militia By The River (1.889)", isJobID: 15, isTab: 2, isCity: 10},
				{isName: "Trade Diamonds For High-Grade Weapons (2.105)", isJobID: 16, isTab: 2, isCity: 10},
				{isName: "Incite The Miners to Riot (2.126)", isJobID: 17, isTab: 2, isCity: 10},
				{isName: "Wage War Against The Mining Corporation (2.086)", isJobID: 18, isTab: 2, isCity: 10},
				{isName: "Establish Yourself As A Rebel Leader (2.19)", isJobID: 19, isTab: 2, isCity: 10},
				{isName: "Distribute The Spoils Of War (2.267)", isJobID: 20, isTab: 2, isCity: 10}
			],
			D3:[ 
				{isName: "Accept The Job For A Top-Secret Mission (1.889)", isJobID: 21, isTab: 3, isCity: 10},
				{isName: "Reach The Medical Facility Without Being Noticed (2.126)", isJobID: 22, isTab: 3, isCity: 10},
				{isName: "Dodge All High Security Elements (2.024)", isJobID: 23, isTab: 3, isCity: 10},
				{isName: "Gain Access To The Disease Containment Chamber (2.126)", isJobID: 24, isTab: 3, isCity: 10},
				{isName: "Eliminate An Unexpected Roadblock (2.024)", isJobID: 25, isTab: 3, isCity: 10},
				{isName: "Open The Virus Vault With Protective Gear (2.227)", isJobID: 26, isTab: 3, isCity: 10},
				{isName: "Take What You Came For (2.126)", isJobID: 27, isTab: 3, isCity: 10},
				{isName: "Flee The Scene Without Leaving A Trail (2.204)", isJobID: 28, isTab: 3, isCity: 10},
				{isName: "Be At The Right Place At The Right Time (2.18)", isJobID: 29, isTab: 3, isCity: 10},
				{isName: "Sell The Virus To The Highest Bidder (2.289)", isJobID: 30, isTab: 3, isCity: 10}
			],
			D4:[
				{isName: "Spy On The Witch Doctor (1.786)", isJobID: 31, isTab: 4, isCity: 10},
				{isName: "Discover The Secret Location Of The Herbs (1.877)", isJobID: 32, isTab: 4, isCity: 10},
				{isName: "Fake An Injury And Seek Doctor's Aid (1.913)", isJobID: 33, isTab: 4, isCity: 10},
				{isName: "Offer A Contract To The Witch Doctor (1.9)", isJobID: 34, isTab: 4, isCity: 10},
				{isName: "Threaten The Doctor To Part With His \"Herbal Meds\" (2.127)", isJobID: 35, isTab: 4, isCity: 10},
				{isName: "Gather A Mob To Force Doctor To Agree (1.99)", isJobID: 36, isTab: 4, isCity: 10},
				{isName: "Set Doctor's House On Fire As A Warning (2.225)", isJobID: 37, isTab: 4, isCity: 10},
				{isName: "Discover That The Doctor Has Escaped (2.162)", isJobID: 38, isTab: 4, isCity: 10},
				{isName: "Launch A Manhunt For Doctor (2.254)", isJobID: 39, isTab: 4, isCity: 10},
				{isName: "Ensure That The Doctor Is In The Boss' Clutches (2.294)", isJobID: 40, isTab: 4, isCity: 10}
			],
			D5:[ 
				{isName: "Acquire Car Parts From Local Hoodlums (1.798)", isJobID: 41, isTab: 5, isCity: 10},
				{isName: "Offer Your Expertise For Their Business (1.875)", isJobID: 42, isTab: 5, isCity: 10},
				{isName: "Go Through A Series Of Tests To Prove Yourself (1.913)", isJobID: 43, isTab: 5, isCity: 10},
				{isName: "Get Recruited For A Lucrative Project (2.139)", isJobID: 44, isTab: 5, isCity: 10},
				{isName: "Proceed To Dealer's Warehouse (1.965)", isJobID: 45, isTab: 5, isCity: 10},
				{isName: "Discover A Special Package In The Car (2.211)", isJobID: 46, isTab: 5, isCity: 10},
				{isName: "Notice That You Are Being Followed (2.246)", isJobID: 47, isTab: 5, isCity: 10},
				{isName: "Lose Them On The Highway (2.238)", isJobID: 48, isTab: 5, isCity: 10},
				{isName: "Bury Your Treasure In A Nearby Field (2.258)", isJobID: 49, isTab: 5, isCity: 10},
				{isName: "Finish Your Car-Jacking Job As Planned (2.302)", isJobID: 50, isTab: 5, isCity: 10}
			],
			D6:[
				{isName: "Assign Your Protege To An Undercover Operation (1.849)", isJobID: 51, isTab: 6, isCity: 10},
				{isName: "Crack Down On Narcotics Rings In The Slums (1.887)", isJobID: 52, isTab: 6, isCity: 10},
				{isName: "Bring Your Protege In On Your Operation (2.154)", isJobID: 53, isTab: 6, isCity: 10},
				{isName: "Stage A Break In Into The Evidence Room (1.951)", isJobID: 54, isTab: 6, isCity: 10},
				{isName: "Find Prospective Buyers In The Mafia (2.196)", isJobID: 55, isTab: 6, isCity: 10},
				{isName: "Resell Snow Candy To The Mafia (2.225)", isJobID: 56, isTab: 6, isCity: 10},
				{isName: "Run A Substance Raid In The Slums (2.24)", isJobID: 57, isTab: 6, isCity: 10},
				{isName: "Fake The Arrest Of Your Protege (2.239)", isJobID: 58, isTab: 6, isCity: 10},
				{isName: "Shift To Another Precinct In The City (2.267)", isJobID: 59, isTab: 6, isCity: 10},
				{isName: "Get Cure For Disease With Your Profits (2.306)", isJobID: 60, isTab: 6, isCity: 10}
			],
			D7:[
				{isName: "Refuse To Poach For Rhino Horns And Ivory (1.874)", isJobID: 61, isTab: 7, isCity: 10},
				{isName: "Give In To Militant Pressure To Poach (1.913)", isJobID: 62, isTab: 7, isCity: 10},
				{isName: "Track Down And Hunt Rhinos (2.154)", isJobID: 63, isTab: 7, isCity: 10},
				{isName: "Make A Futile Attempt To Escape Rangers (2.184)", isJobID: 64, isTab: 7, isCity: 10},
				{isName: "Endure Torture During Interrogation (2.211)", isJobID: 65, isTab: 7, isCity: 10},
				{isName: "Cut A Deal With Rangers (2.224)", isJobID: 66, isTab: 7, isCity: 10},
				{isName: "Lead Rangers To Closest Militant Hideout (2.232)", isJobID: 67, isTab: 7, isCity: 10},
				{isName: "Take Cover From Gunfire (2.246)", isJobID: 68, isTab: 7, isCity: 10},
				{isName: "Expose Other Militant Pockets (2.296)", isJobID: 69, isTab: 7, isCity: 10},
				{isName: "Become An Informer For The Rangers (2.313)", isJobID: 70, isTab: 7, isCity: 10}
			],
			D8:[
				{isName: "Launch An Assault On The Football Stadium (2.09)", isJobID: 71, isTab: 8, isCity: 10},
				{isName: "Demand That The President Be Surrendered To You (1.926)", isJobID: 72, isTab: 8, isCity: 10},
				{isName: "Give The President Time To Escape (2.267)", isJobID: 73, isTab: 8, isCity: 10},
				{isName: "Launch Deadly Virus Grenades Into The Crowd (2.196)", isJobID: 74, isTab: 8, isCity: 10},
				{isName: "Abduct The Nation's Most Influential Media Mogul (2.296)", isJobID: 75, isTab: 8, isCity: 10},
				{isName: "Blow Up The Grounded Blimp To Cover Your Escape (2.241)", isJobID: 76, isTab: 8, isCity: 10},
				{isName: "Secure The Hideout While You Wait For The Boss (2.311)", isJobID: 77, isTab: 8, isCity: 10},
				{isName: "Persuade The Mogul To Join Your Cause (2.282)", isJobID: 78, isTab: 8, isCity: 10},
				{isName: "Release Footage Of The President Abandoning The Stadium Victims (2.366)", isJobID: 79, isTab: 8, isCity: 10},
				{isName: "Influence Public Opinion Through The Mogul's News Networks (2.395)", isJobID: 80, isTab: 8, isCity: 10}
			],
			D9:[
				{isName: "Alert President Of Public Frenzy (1.964)", isJobID: 81, isTab: 9, isCity: 10},
				{isName: "Call For A Meeting In A Secluded Location (2.224)", isJobID: 82, isTab: 9, isCity: 10},
				{isName: "Join President's Entourage At Springbok (2.296)", isJobID: 83, isTab: 9, isCity: 10},
				{isName: "Protect President From Public Humiliation (2.239)", isJobID: 84, isTab: 9, isCity: 10},
				{isName: "Transport President To Safe House (2.254)", isJobID: 85, isTab: 9, isCity: 10},
				{isName: "Double-Cross the President (2.324)", isJobID: 86, isTab: 9, isCity: 10},
				{isName: "Force President To Confront His Past (2.26)", isJobID: 87, isTab: 9, isCity: 10},
				{isName: "Record President's Confession To Crimes Of Genocide (2.285)", isJobID: 88, isTab: 9, isCity: 10},
				{isName: "Tip-Off President's Whereabouts To Police (2.387)", isJobID: 89, isTab: 9, isCity: 10},
				{isName: "Escape Safe House Unnoticed (2.401)", isJobID: 90, isTab: 9, isCity: 10}
			],
			D10:[
				{isName: "Gain The Cooperation Of Key Members Of Parliament (2.163)", isJobID: 91, isTab: 10, isCity: 10},
				{isName: "Take Control Of The Leading Political Party (2.225)", isJobID: 92, isTab: 10, isCity: 10},
				{isName: "Organize Terror Attacks By Your Militants (2.296)", isJobID: 93, isTab: 10, isCity: 10},
				{isName: "Double Cross And Have Them Eliminated (2.222)", isJobID: 94, isTab: 10, isCity: 10},
				{isName: "Declare A State Of Emergency In The Country (2.253)", isJobID: 95, isTab: 10, isCity: 10},
				{isName: "Establish Martial Law (2.282)", isJobID: 96, isTab: 10, isCity: 10},
				{isName: "Offer Restitution To Terror Attack Victims (2.270)", isJobID: 97, isTab: 10, isCity: 10},
				{isName: "Publicize Your Philanthropy To Win Public Approval (2.290)", isJobID: 98, isTab: 10, isCity: 10},
				{isName: "Get Sworn In As President (2.416)", isJobID: 99, isTab: 10, isCity: 10},
				{isName: "Offer Your Associates Key Roles In The Cabinet (2.423)", isJobID: 120, isTab: 10, isCity: 10}
				/*
					{isName: "Gain The Cooperation Of Key Members Of Parliament (2.163)", isJobID: 91, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Take Control Of The Leading Political Party (2.225)", isJobID: 92, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Organize Terror Attacks By Your Militants (2.296)", isJobID: 93, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Double Cross And Have Them Eliminated (2.205)", isJobID: 94, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Declare A State Of Emergency In The Country (2.253)", isJobID: 95, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Establish Martial Law (2.324)", isJobID: 96, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Offer Restitution To Terror Attack Victims (2.270)", isJobID: 97, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Publicize Your Philanthropy To Win Public Approval (2.290)", isJobID: 98, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Get Sworn In As President (2.416)", isJobID: 99, isTab: 10, isCity: 10, isCost: 0},
					{isName: "Offer Your Associates Key Roles In The Cabinet (2.423)", isJobID: 120, isTab: 10, isCity: 10, isCost: 0}
				*/
			]
		};	
		
		var MEXJobMap = {
			D1:[
				{isName: "Rob Rival Cartel's Latest Shipment (1.851)", isJobID: 1, isTab: 1, isCity: 11},
				{isName: "Escape Cartel's Retaliation (1.859)", isJobID: 2, isTab: 1, isCity: 11},
				{isName: "Visit Your Go-Down To Check On The Goods (2.039)", isJobID: 3, isTab: 1, isCity: 11},
				{isName: "Receive A Threat That Is Loud But Not So Clear (1.884)", isJobID: 4, isTab: 1, isCity: 11},
				{isName: "Extort Vital Information From Local Peddlers (1.942)", isJobID: 5, isTab: 1, isCity: 11},
				{isName: "Dispose Of Them Once You've Heard Enough (2.013)", isJobID: 6, isTab: 1, isCity: 11},
				{isName: "Declare War On Rival's Hacienda (1.993)", isJobID: 7, isTab: 1, isCity: 11},
				{isName: "Put An End To This Rivalry Once And For All (2.075)", isJobID: 8, isTab: 1, isCity: 11},
				{isName: "Retrieve All That Was Yours And More (2.076)", isJobID: 9, isTab: 1, isCity: 11},
				{isName: "Offer Cops Plata O Plomo To Run A Smooth Operation (2.124)", isJobID: 10, isTab: 1, isCity: 11}
			],
			D2:[
				{isName: "Reward Your Cartel Moles For Inside Information (2.089)", isJobID: 11, isTab: 2, isCity: 11},
				{isName: "Recruit Ex-Elite Commandos To Strengthen Your Mafia (2.105)", isJobID: 12, isTab: 2, isCity: 11},
				{isName: "Use Your Crew To Intimidate The Cartel's Thugs (2.236)", isJobID: 13, isTab: 2, isCity: 11},
				{isName: "Take Control Of Product Distribution On The Streets (2.144)", isJobID: 14, isTab: 2, isCity: 11},
				{isName: "Orchestrate A Jail Break To Keep The Federales Busy (2.080)", isJobID: 15, isTab: 2, isCity: 11},
				{isName: "Recruit The Convicts With The Most Useful Skills (2.080)", isJobID: 16, isTab: 2, isCity: 11},
				{isName: "Steal Military Surplus To Get Equipped For The Showdown (2.233)", isJobID: 17, isTab: 2, isCity: 11},
				{isName: "Use Superior Military Tactics To Take Down The Cartel (2.159)", isJobID: 18, isTab: 2, isCity: 11},
				{isName: "Establish Smooth Supply Through Monopolized Routes (2.232)", isJobID: 19, isTab: 2, isCity: 11},
				{isName: "Grow The Operation To Facilitate Trans-Atlantic Trafficking (2.255)", isJobID: 20, isTab: 2, isCity: 11}
			],
			D3:[ 
				{isName: "Escape Through The Desert With Fellow Immigrants (2.095)", isJobID: 21, isTab: 3, isCity: 11},
				{isName: "Fight Back When Coyotes Turn On You (2.119)", isJobID: 22, isTab: 3, isCity: 11},
				{isName: "Make Your Way Through The Desert To Safety (2.080)", isJobID: 23, isTab: 3, isCity: 11},
				{isName: "Stumble Upon A Cartel's Secret Goods Drop (2.208)", isJobID: 24, isTab: 3, isCity: 11},
				{isName: "Wait For Nightfall To Steal The Cartel's Money (2.101)", isJobID: 25, isTab: 3, isCity: 11},
				{isName: "Set Goods On Fire To Distract The Guards (2.233)", isJobID: 26, isTab: 3, isCity: 11},
				{isName: "Retrieve The Child From His Hiding Place (2.136)", isJobID: 27, isTab: 3, isCity: 11},
				{isName: "Kill To Protect The Only Family You Have Left (2.136)", isJobID: 28, isTab: 3, isCity: 11},
				{isName: "Stow Away On Goods Delivery Plane (2.280)", isJobID: 29, isTab: 3, isCity: 11},
				{isName: "Bribe The Pilot When You're Discovered (2.323)", isJobID: 30, isTab: 3, isCity: 11}
			],
            D4:[
                {isName: "Arrange The Sale Of Your New Weapons Shipment (2.069)", isJobID: 31, isTab: 4, isCity: 11},
                {isName: "Refuse To Deliver Until The Cobrizo Cartel Pays In Full (2.098)", isJobID: 32, isTab: 4, isCity: 11},
                {isName: "Accept Your Brother's Help To Transport The Shipment (2.118)", isJobID: 33, isTab: 4, isCity: 11},
                {isName: "Fend Off An Attack On The Way To The Weapons Cache (2.213)", isJobID: 34, isTab: 4, isCity: 11},
                {isName: "Give Up Your Hideout In Exchange For Your Life (2.163)", isJobID: 35, isTab: 4, isCity: 11},
                {isName: "Transport The Shipment To The Cobrizo Warehouse (2.232)", isJobID: 36, isTab: 4, isCity: 11},
                {isName: "Invite The Cobrizo Cartel To Inspect New Merchandise (2.111)", isJobID: 37, isTab: 4, isCity: 11},
                {isName: "Avoid The Cross-Fire As Interpol Makes Arrests (2.268)", isJobID: 38, isTab: 4, isCity: 11},
                {isName: "Track Down Your Brother At The Cobrizo Safe House (2.204)", isJobID: 39, isTab: 4, isCity: 11},
                {isName: "Make Peace With Your Decision To Get Revenge (2.301)", isJobID: 40, isTab: 4, isCity: 11}
            ],
            D5:[ 
                {isName: "Abduct Passed Out Party Goers (2.097)", isJobID: 41, isTab: 5, isCity: 11},
                {isName: "Harvest Organs For Smuggling (2.126)", isJobID: 42, isTab: 5, isCity: 11},
                {isName: "Accompany Team On Lucrative Operation (2.217)", isJobID: 43, isTab: 5, isCity: 11},
                {isName: "Be Rescued By A Group Of Autodefensas (2.101)", isJobID: 44, isTab: 5, isCity: 11},
                {isName: "Refuse Doctor's Diagnosis Of Amnesia (2.059)", isJobID: 45, isTab: 5, isCity: 11},
                {isName: "Attempt To Unravel Your Identity (2.235)", isJobID: 46, isTab: 5, isCity: 11},
                {isName: "Reject Your Mafia's Proposal To Rejoin Family (2.114)", isJobID: 47, isTab: 5, isCity: 11},
                {isName: "Cut Off All Ties With Your Mafia (2.271)", isJobID: 48, isTab: 5, isCity: 11},
                {isName: "Embrace Autodefensas' Ideology As Your Own (2.173)", isJobID: 49, isTab: 5, isCity: 11},
                {isName: "Put An End To Your Ex-MafiaÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢s Operations (2.317)", isJobID: 50, isTab: 5, isCity: 11}
            ],
			D6:[ 
				{isName: "Lure The Casino Owner's Wife Away From The Party (2.113)", isJobID: 51, isTab: 6, isCity: 11},
				{isName: "Demand A Ransom From The Casino Owner (2.195)", isJobID: 52, isTab: 6, isCity: 11},
				{isName: "Hold Up Under Intense Interrogation (2.164)", isJobID: 53, isTab: 6, isCity: 11},
				{isName: "Have Your 'Lawyer' Plant The Call Jammer (2.245)", isJobID: 54, isTab: 6, isCity: 11},
				{isName: "Evade The Police At The Ransom Drop Site (2.195)", isJobID: 55, isTab: 6, isCity: 11},
				{isName: "Snatch The Casino Owner In The Confusion (2.249)", isJobID: 56, isTab: 6, isCity: 11},
				{isName: "Use The Owner To Get Past Casino Security (2.245)", isJobID: 57, isTab: 6, isCity: 11},
				{isName: "Empty The Vault Before The Guards Wise Up (2.258)", isJobID: 58, isTab: 6, isCity: 11},
				{isName: "Get Rid Of Excess Baggage (2.290)", isJobID: 59, isTab: 6, isCity: 11},
				{isName: "Lie Low Until The Excitement Dies Down (2.319)", isJobID: 60, isTab: 6, isCity: 11}
			],
			D7:[ 
				{isName: "Meet With A Don To Accept A Contract (2.204)", isJobID: 61, isCity: 11, isTab: 7},
				{isName: "Escape When You're Set Up For His Murder (2.257)", isJobID: 62, isCity: 11, isTab: 7},
				{isName: "Force Police Involvement By Faking a Tip (2.184)", isJobID: 63, isCity: 11, isTab: 7},
				{isName: "Equip Yourself At The Station's Armory (2.281)", isJobID: 64, isCity: 11, isTab: 7},
				{isName: "Storm The Warehouse To Rescue Your Comrades (2.225)", isJobID: 65, isCity: 11, isTab: 7},
				{isName: "Hide Evidence Of Their Criminal Double Life (2.282)", isJobID: 66, isCity: 11, isTab: 7},
				{isName: "Chase Down The Old Don's Lieutenant (2.230)", isJobID: 67, isCity: 11, isTab: 7},
				{isName: "Record His Confession To Killing The Don (2.294)", isJobID: 68, isCity: 11, isTab: 7},
				{isName: "Deliver The Lieutenant To The Don's Family (2.267)", isJobID: 69, isCity: 11, isTab: 7},
				{isName: "Split The Reward Between Your Comrades' Families (2.334)", isJobID: 70, isCity: 11, isTab: 7}
			],
			D8:[ 
				{isName: "Practice Free Climbing At An Old Temple (2.211)", isJobID: 71, isCity: 11, isTab: 8},
				{isName: "Stumble On Ancient Mayan Treasures (2.246)", isJobID: 72, isCity: 11, isTab: 8},
				{isName: "Have Your Applications For The Contest Rejected (2.235)", isJobID: 73, isCity: 11, isTab: 8},
				{isName: "Bribe An Organizer To Squeeze You Into The Contest (2.287)", isJobID: 74, isCity: 11, isTab: 8},
				{isName: "Give Into The Greedy Organizer's Demands For More (2.293)", isJobID: 75, isCity: 11, isTab: 8},
				{isName: "Hand Over The Treasure In Exchange For Your Lives (2.210)", isJobID: 76, isCity: 11, isTab: 8},
				{isName: "Escape While The Organizer Deals With Your Friends (2.267)", isJobID: 77, isCity: 11, isTab: 8},
				{isName: "Follow Your Treasure (2.253)", isJobID: 78, isCity: 11, isTab: 8},
				{isName: "Deduce The Organizer's New Hiding Place (2.303)", isJobID: 79, isCity: 11, isTab: 8},
				{isName: "Bide your Time Until You Can Exact Revenge (2.348)", isJobID: 80, isCity: 11, isTab: 8}
			],
			D9:[ 
				{isName: "Meet A Rich Mining Boss Regarding A Secret Op (2.136)", isJobID: 81, isCity: 11, isTab: 9},
				{isName: "Accept Job And Ask To Use His Boats As Payment (2.187)", isJobID: 82, isCity: 11, isTab: 9},
				{isName: "Cause 'Accidents' On The Rival's Mine (2.219)", isJobID: 83, isCity: 11, isTab: 9},
				{isName: "Discover That The Boss Has Gone Back On His Word (2.149)", isJobID: 84, isCity: 11, isTab: 9},
				{isName: "Seek Fair Share Of Profits Among Other Demands (2.228)", isJobID: 85, isCity: 11, isTab: 9},
				{isName: "Use Force To Take Over Both Mines (2.198)", isJobID: 86, isCity: 11, isTab: 9},
				{isName: "Conduct A Dry Run On Your Smuggling Operations (2.232)", isJobID: 87, isCity: 11, isTab: 9},
				{isName: "Move Out Your Large Shipment Secretly (2.16)", isJobID: 88, isCity: 11, isTab: 9},
				{isName: "Discover You've Become The Target Of The Mining Lords (2.239)", isJobID: 89, isCity: 11, isTab: 9},
				{isName: "Escape An Attempt On Your Life (2.26)", isJobID: 90, isCity: 11, isTab: 9}
			],		
			D10:[ 
				{isName: "Escape The Raid On Your Packaging Unit (2.101)", isJobID: 91, isCity: 11, isTab: 10},
				{isName: "Track Your Seized Goods To The Comisaria (2.125)", isJobID: 92, isCity: 11, isTab: 10},
				{isName: "Send Your Partner To Make A Deal With The Police (1.965)", isJobID: 93, isCity: 11, isTab: 10},
				{isName: "Hear Of His Incarceration When He Refuses To Betray You (2.14)", isJobID: 94, isCity: 11, isTab: 10},
				{isName: "Sabotage The Bull Pens To Create A Diversion (2.022)", isJobID: 95, isCity: 11, isTab: 10},
				{isName: "Separate The Attorney General From His Security Detail (2.104)", isJobID: 96, isCity: 11, isTab: 10},
				{isName: "Get Your Revenge On The Attorney General (2.169)", isJobID: 97, isCity: 11, isTab: 10},
				{isName: "Use His Death To Instigate Riots Across The city (2.064)", isJobID: 98, isCity: 11, isTab: 10},
				{isName: "Attack The Comisaria To Free Your Partner (2.105)", isJobID: 99, isCity: 11, isTab: 10},
				{isName: "Steal Back All Your Confiscated Goods (2.214)", isJobID: 100, isCity: 11, isTab: 10}
			],
			D11:[ 
				{isName: "Crash The Meeting Between Your Rival And His Customer (1.888)", isJobID: 101, isCity: 11, isTab: 11},
				{isName: "Steal The Data That Was Being Sold (2.045)", isJobID: 102, isCity: 11, isTab: 11},
				{isName: "Draw Your Rival Away So Your Team Can Escape (2.098)", isJobID: 103, isCity: 11, isTab: 11},
				{isName: "Destroy Your Truck When He Loses Your Trail (2.01)", isJobID: 104, isCity: 11, isTab: 11},
				{isName: "Survive The Perils Of The Desert At Night (2.103)", isJobID: 105, isCity: 11, isTab: 11},
				{isName: "Rendezvous With Your Team At A Secure Location (2.069)", isJobID: 106, isCity: 11, isTab: 11},
				{isName: "Hide In Plain Sight To Enter The Locked-Down Town (2.032)", isJobID: 107, isCity: 11, isTab: 11},
				{isName: "Send Out Feelers To Potential Buyers (2.045)", isJobID: 108, isCity: 11, isTab: 11},
				{isName: "Go On The Offensive And Track Down Your Rival (2.112)", isJobID: 109, isCity: 11, isTab: 11},
				{isName: "Eliminate The Threat Of His Retribution (2.16)", isJobID: 110, isCity: 11, isTab: 11}
			]
		};	
			
		var StamJobs = new Array(
			{isName: "Gain The Cooperation Of Key Members Of Parliament (2.163)", isJobID: 91, isCity: 10, isCost: 0, isTab: 10, isTheXP: 0, isRatio:0, isMastered:DroneX.Imgs.RubyStar},
			{isName: "Double Cross And Have Them Eliminated (2.222)", isJobID: 94, isCity: 10, isCost: 0, isTab: 10, isTheXP: 0, isRatio:0, isMastered:DroneX.Imgs.RubyStar},
			{isName: "Offer Restitution To Terror Attack Victims (2.270)", isJobID: 97, isCity: 10, isCost: 0, isTab: 10, isTheXP: 0, isRatio:0, isMastered:DroneX.Imgs.RubyStar},
			{isName: "Send Your Partner To Make A Deal With The Police (2.168)", isJobID: 93, isCity: 11, isCost: 0, isTab: 10, isTheXP: 0, isRatio:0, isMastered:DroneX.Imgs.RubyStar},
			{isName: "Sabotage The Bull Pens To Create A Diversion (2.232)", isJobID: 95, isCity: 11, isCost: 0, isTab: 10, isTheXP: 0, isRatio:0, isMastered:DroneX.Imgs.RubyStar},
			{isName: "Use His Death To Instigate Riots Across The city (2.277)", isJobID: 98, isCity: 11, isCost: 0, isTab: 10, isTheXP: 0, isRatio:0, isMastered:DroneX.Imgs.RubyStar}
		);
		
		$('a[id^="travel_menu_secret_"]').each(function(){
			SecretDistrictCounter++;
			var isName = $(this).text().trim();
			var isLink = $(this).prop('onclick');
			var isTab = /tab=(\d+)/.exec(isLink)[1];
			var isCity = /destination=(\d+)/.exec(isLink)[1];
			var new_district = {isName:isName, isTab:isTab, isCity:isCity};
			DroneX.SDMap.push(new_district);
		});
		
		function create_div() {
			if(document.getElementById('gxDiv')) {
				document.getElementById('gxDiv').innerHTML = MainIndexOf;
			} else {
				var gxDiv=document.createElement("div");
				gxDiv.id = 'gxDiv';
				gxDiv.style = 'padding: 5px;';
				var content=document.getElementById('content_row');
				content.insertBefore(gxDiv, content.firstChild);
				document.getElementById('gxDiv').innerHTML = MainIndexOf;
			}
		}

		readSettings();
		var DroneX_Stylez = '<style type="text/css">'+
		'.DroneX_Box {float: left;overflow-x: hidden;width: 522px;}'+
		'.DroneX_TabBox {height: 27px;overflow: hidden;}'+
		'.DroneX_Tab {float: left;}'+
		'.DroneX_TabActive {opacity: 1;}'+
		'.DroneX_TabInActive {opacity: 0.7;}'+
		'.DroneX_TabStart {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/black_tabs_left.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);float: left;height: 28px;width: 3px;}'+
		'.DroneX_TabMiddle {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/black_tabs_slice.png") repeat scroll 0 0 rgba(0, 0, 0, 0);color: #FFFFFF;float: left;font-size: 14px;height: 28px;padding-left: 5px;padding-right: 10px;padding-top: 5px;}'+
		'.DroneX_TabEnd {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/black_tabs_right.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);float: left;height: 28px;width: 3px;}'+
		'.DroneX_TabContent {background-color: #111111;border: 1px solid #666666;overflow: hidden;}'+
		'.DroneX_TabContentDiv {height: 230px;margin-left: 10px;overflow: auto;}'+
		//arena
		'.messages {border: 1px solid #888888; margin-bottom: 5px; -moz-border-radius: 5px; border-radius: 5px; -webkit-border-radius: 5px;}'+
		'.messages img{margin:0 3px;vertical-align:middle}'+
		'.messages input {border: 1px solid #888888; -moz-border-radius: 3px; border-radius: 3px; -webkit-border-radius: 2px;padding 0;background: #000; color: #FFF; width: 32px; margin:1px;}'+
		'#DXspartacus_table td { padding:3px; }'+
		'#DXspartacus_table th { padding:3px; }'+
		'#DXspartacus_table { width:100%; border: 1px solid black; }'+
		'#DXspartacus_table tr:nth-child(odd) { background: #181818; }'+
		'.DXspartacus_teamblue { background: #0E374B !important;}'+
		'.DXspartacus_teamred { background: #331A1E !important;}'+
		'.DXspartacus_usepowerup { cursor:pointer; }'+
		'.DXspartacus_notusepowerup { cursor:default; }'+
		'.DXspartacus_puclick { cursor:pointer; }'+
		'.DXspartacus_punoclick { cursor:default; }'+
		'.DXspartacus_pufull { opacity:1; }'+
		'.DXspartacus_puhalf { opacity:0.6; }'+
		'.DXspartacus_puoff { opacity:0.2; }'+
		'.DXspartacus_puactive { border:1px solid white; }'+
		'.DXspartacus_punormal { border:1px solid #101010; }'+
		'.DXspartacus_conf { display:none; }'+
		'#DXspartacus_delay { display:none; }'+
		'.DXspartacus_offsh {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/Effect_opponentOverlay.png") 0 50% no-repeat;background-position:-10px -5px;padding-left: 30px;}'+
		'.DXspartacus_defsh {background: url("https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/Effect_opponentOverlay.png") 0 50% no-repeat;background-position:-230px -110px;padding-left: 30px;}'+
		'.DXspartacus_lootlog { display:none; }'+
		'.DXspartacus_arenalog { display:none; }'+
		'</style>';
		
		var ChangeLogInfoz = 'Change Log: <br><br>' +
		'<span class="good">[v0.21]</span> &nbsp; <span class="more_in">[1st December 2014]</span><br> - Restored Backup of 20C and added in D11 of Mexico. <br><br>'+			
		'<span class="good">[v0.20C]</span> &nbsp; <span class="more_in">[5 October 2014]</span><br> - C is for cookie aka spartacus issue hopefully patched. <br><br>'+		
		'<span class="good">[v0.20]</span> &nbsp; <span class="more_in">[14 September 2014]</span><br> - With special thanks to Patrick, i have now fixed the mexico boss issue. <br><br>'+		
		'<span class="good">[v0.19a]</span> &nbsp; <span class="more_in">[29 August 2014]</span><br> - Added in Mexico districts 7 & 8. <br><br>'+
		'<span class="good">[v0.19]</span> &nbsp; <span class="more_in">[3 July 2014]</span><br> - Added in Mexico district 6. <br> - Started hpage background image removal. Will re host. <br><br>'+
		'<span class="good">[v0.18]</span> &nbsp; <span class="more_in">[1 July 2014]</span><br> - Added in Mexico districts 4 and 5.<br><br>'+
		'<span class="good">[v0.17]</span> &nbsp; <span class="more_in">[11 June 2014]</span><br> - Added in background switching. <br> - Added in Spartacus v1.28 by Spockholm. <br><br>'+
		'<span class="good">[v0.16]</span> &nbsp; <span class="more_in">[27 May 2014]</span><br> - Added in OfficerJAKEs\' Change log. <br> - Added Idle City. <br> - Added Auto Bandit Shuffle. <br> - Added Mexico for Robbing & Fighting. <br> - Added option to stay always healed. <br><br>'+
		'<span class="good">[v0.15]</span> &nbsp; <span class="more_in">[09 May 2014]</span><br> - Mexico jobs have been added in. <br> - Testing code to auto change job/xp costs when boss detected in Mexico. <br><br>'+
		'<span class="good">[v0.14]</span> &nbsp; <span class="more_in">[04 May 2014]</span><br> - Added in CSS code and tips from OfficerJAKE. <br> - Removed backup job on jobpage until code for it is added in. <br> - Trialing skipping jobs when bandits appear, however it is a manual click. <br><br>'+
		'<span class="good">[v0.13]</span> &nbsp; <span class="more_in">[28 April 2014]</span><br> - Killer Kami has been added. <br><br>'+
		'<span class="good">[v0.12]</span> &nbsp; <span class="more_in">[20 April 2014]</span><br> - Fixed the restart bug and log. <br> - Added in family XP collector. <br><br>'+
		'<span class="good">[v0.11]</span> &nbsp; <span class="more_in">[19 April 2014]</span><br> - Options for Marathon Stats was removed. <br> - Individual job counters were added in. <br> - Restart timer was made adjustable. <br> - Secret district jobs will now save. <br><br>'+
		'<span class="good">[v0.10]</span> &nbsp; <span class="more_in">[15 April 2014]</span><br> - Options for Marathon Stats added in. <br> - Option added to stop at level. <br> - Option added to remove jobs when out of cash or consumables. <br><br>';
		
	var optable = 
		'<tr><th style="width: 55px; height:20px;">Rank<img height="16" width="16" src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/item_treasure_chest_key.gif" id="DXspartacus_lockrank" style="display:none;" /></th>'+
		'<th>Opponent</th><th>Info</th><th>Respect</th><th style="width:65px;">Health</th><th>Score</th><th>Stamina</th><th style="width:80px;">Shields</th><th>Intervene</th></tr>'+
		'<tr id="DXspartacus_op0"><td style="height:38px;"><span id="DXspartacus_rank0">#1</span></td><td><span id="DXspartacus_name0">Opponent 0</span></td><td><span id="DXspartacus_diff0" class="difficulty"></span></td><td><span id="DXspartacus_respect0" class="respect">0</span></td><td><span class="health" id="DXspartacus_health0">0</span></td><td><span id="DXspartacus_score0">0</span></td><td><span id="DXspartacus_stam0" class="stamina">?</span></td><td><span id="DXspartacus_pu0"></span></td><td><span id="DXspartacus_usepu0"></span></td></tr>'+
		'<tr id="DXspartacus_op1"><td style="height:38px;"><span id="DXspartacus_rank1">#2</span></td><td><span id="DXspartacus_name1">Opponent 1</span></td><td><span id="DXspartacus_diff1" class="difficulty"></span></td><td><span id="DXspartacus_respect1" class="respect">0</span></td><td><span class="health" id="DXspartacus_health1">0</span></td><td><span id="DXspartacus_score1">0</span></td><td><span id="DXspartacus_stam1" class="stamina">?</span><td><span id="DXspartacus_pu1"></span></td><td><span id="DXspartacus_usepu1"></span></td></tr>'+
		'<tr id="DXspartacus_op2"><td style="height:38px;"><span id="DXspartacus_rank2">#3</span></td><td><span id="DXspartacus_name2">Opponent 2</span></td><td><span id="DXspartacus_diff2" class="difficulty"></span></td><td><span id="DXspartacus_respect2" class="respect">0</span></td><td><span class="health" id="DXspartacus_health2">0</span></td><td><span id="DXspartacus_score2">0</span></td><td><span id="DXspartacus_stam2" class="stamina">?</span><td><span id="DXspartacus_pu2"></span></td><td><span id="DXspartacus_usepu2"></span></td></tr>'+
		'<tr id="DXspartacus_op3"><td style="height:38px;"><span id="DXspartacus_rank3">#4</span></td><td><span id="DXspartacus_name3">Opponent 3</span></td><td><span id="DXspartacus_diff3" class="difficulty"></span></td><td><span id="DXspartacus_respect3" class="respect">0</span></td><td><span class="health" id="DXspartacus_health3">0</span></td><td><span id="DXspartacus_score3">0</span></td><td><span id="DXspartacus_stam3" class="stamina">?</span><td><span id="DXspartacus_pu3"></span></td><td><span id="DXspartacus_usepu3"></span></td></tr>'+
		'<tr id="DXspartacus_op4"><td style="height:38px;"><span id="DXspartacus_rank4">#5</span></td><td><span id="DXspartacus_name4">Opponent 4</span></td><td><span id="DXspartacus_diff4" class="difficulty"></span></td><td><span id="DXspartacus_respect4" class="respect">0</span></td><td><span class="health" id="DXspartacus_health4">0</span></td><td><span id="DXspartacus_score4">0</span></td><td><span id="DXspartacus_stam4" class="stamina">?</span><td><span id="DXspartacus_pu4"></span></td><td><span id="DXspartacus_usepu4"></span></td></tr>'+
		'<tr id="DXspartacus_op5"><td style="height:38px;"><span id="DXspartacus_rank5">#6</span></td><td><span id="DXspartacus_name5">Opponent 5</span></td><td><span id="DXspartacus_diff5" class="difficulty"></span></td><td><span id="DXspartacus_respect5" class="respect">0</span></td><td><span class="health" id="DXspartacus_health5">0</span></td><td><span id="DXspartacus_score5">0</span></td><td><span id="DXspartacus_stam5" class="stamina">?</span><td><span id="DXspartacus_pu5"></span></td><td><span id="DXspartacus_usepu5"></span></td></tr>';
		
//https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/empire/mexico_hp_bg.jpg
//https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/empire/london_hp_bg.png
			var MainIndexOf = '<div id="BGS" style="background-color: #000000;border: 1px solid #666666;border-radius: 3px 3px 3px 3px;color: #FFFFFF; width: 747px; height: 490px; background: background-size: 100%;">'+
			'<div style="background: url(https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/empire/header_module_gradient.gif) repeat-x scroll 0 0 ;color: #FFCF01; font-size: 17px;font-weight: bold;height: 22px;width:737px; padding-left: 10px;padding-top: 10px;text-transform: uppercase;">Drone.&#12324;<span title="NEW DRONE.X (ND) - The woofs have infiltrated and left their mark!">(ND)</span> v'+DroneX.Version+'	<span style="float:right"><a style="padding-right: 10px;margin-top:-14px;display:none;" class="sexy_button_new short orange" id="DxAS"><span><span> Autostarting... (stop) </span></span></a><a style="padding-right: 10px;margin-top:-14px;" class="sexy_button_new short green" id="start"><span><span>GO!</span></span></a><a href="#" style="padding-right: 10px;margin-top:-14px;display:none;" class="sexy_button_new short red" id="stop"><span><span>Stop</span></span></a><a href="#" style="padding-right: 10px;margin-top:-14px;" class="sexy_button_new short orange" id="close"><span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/iced.png"></span></span></a></span></div>'+
				DroneX_Stylez+
				'<div style="width: 720px; padding: 0 7px; float: none; " class="DroneX_Box"> '+
					'<div style="height: 35px; border-bottom: 1px solid #333;" class="DroneX_TabBox">	'+
						'<div onclick="LoadDroneXMain();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="DroneX_Tab DroneX_TabInActive" id="DroneX_MainTab">'+
							'<div class="DroneX_TabStart">&nbsp;</div>'+
							'<div class="DroneX_TabMiddle">Main</div>'+
							'<div class="DroneX_TabEnd">&nbsp;</div>'+
						'</div>'+
						'<div onclick="LoadDroneXConfig();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="DroneX_Tab DroneX_TabInActive" id="DroneX_ConfigTab">'+
							'<div class="DroneX_TabStart">&nbsp;</div>'+
							'<div class="DroneX_TabMiddle">Config</div>'+
							'<div class="DroneX_TabEnd">&nbsp;</div>'+
						'</div>'+
						'<div onclick="LoadDroneXJobSetup();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="DroneX_Tab DroneX_TabActive" id="DroneX_JobSetupTab">'+
							'<div class="DroneX_TabStart">&nbsp;</div>'+
							'<div class="DroneX_TabMiddle">Job Selection</div>'+
							'<div class="DroneX_TabEnd">&nbsp;</div>'+
						'</div>'+
						'<div onclick="LoadDroneXJobList();" style="margin-right: 3px; cursor: pointer; padding-top: 8px" class="DroneX_Tab DroneX_TabInActive" id="DroneX_JobListTab">'+
							'<div class="DroneX_TabStart">&nbsp;</div>'+
							'<div class="DroneX_TabMiddle">Job List</div>'+
							'<div class="DroneX_TabEnd">&nbsp;</div>'+
						'</div>'+
						'<div onclick="LoadDroneXChangeLog();" style="float:right; cursor: pointer; padding-top: 8px" class="DroneX_Tab DroneX_TabInActive" id="DroneX_ChangeLogTab">'+
							'<div class="DroneX_TabStart">&nbsp;</div>'+
							'<div class="DroneX_TabMiddle">Change Log</div>'+
							'<div class="DroneX_TabEnd">&nbsp;</div>'+
						'</div>'+						
					'</div>'+
					'<div style="background-color: transparent; border: none;" class="DroneX_TabContent">'+
						'<div style="overflow: auto; height: 395px; margin-right: 0px; overflow-x: hidden;" class="DroneX_TabContentDiv">'+
							'<div style="display: none;" id="DroneX_Main">'+
							'Job List: <span id="JobList" class="energy_highlight"></span><br>'+
							'Job: <span id="ActiveJob" class="energy_highlight"></span><br><br>'+
							'Status: <span id="Activity"></span><br><br>'+
							'Last Levelup: <span id="LastLvlUp" class="energy_highlight"></span><br><br>'+
							'Total Job Counter: <span id="TotalJobsDone" class="energy_highlight">0</span><br><br>'+
							'Levelups: <span id="LvlUps" class="energy_highlight">'+DroneX.Saving.LvlupCounter+'</span><br><br>'+
							'<span id="newfightx"></span><br><br>'+
	//						'Some more text here for the main'+ 
		'<div id="gxRDivS" style="clear:both; display:none;">'+
	'<table style="width:100%;">'+
		'<tr><td width="150">Stage:</td><td colspan=2><table width="100%"><tr><td><span id="DXspartacus_stage">Not started</span></td><td>Connection: <span id="DXspartacus_connstatus">-</span> <span id="DXspartacus_connstatus2"></span> <span id="DXspartacus_delay"></span></td><td>Crests: <span class="arena_mastery_crests" id="DXspartacus_crests">Loading...</span></td></tr></table></td></tr>'+
		'<tr><td valign="top">Time left:</td><td colspan="2"><span id="DXspartacus_timeleftbar"></span></td></tr>'+
		'<tr><td valign="top">Power-Ups<br /><span class="more_in">(Click to use)</span>:</td><td colspan="2" valign="top"><span id="DXspartacus_powerups"></span></td></tr>'+
		'<tr><td valign=top>Strength:</td><td colspan="2"><span id="DXspartacus_strength_stats"></span></td></tr>'+
		'<tr><td>Stamina:</td><td colspan="2"><span class="stamina" id="DXspartacus_me_st">0</span>, next +<span id="DXspartacus_replenish">?</span> in <span id="DXspartacus_me_sr">0</span>s, used: <span class="stamina" id="DXspartacus_me_stused">0</span></td></tr>'+
		'<tr><td>Health:</td><td colspan="2"><span class="health" id="DXspartacus_me_health">100</span>% &nbsp; <span id="DXspartacus_healin"></span></td></tr>'+
		'<tr><td>Teamscores:</td><td colspan="2"><span id="DXspartacus_teamscore"></span></td></tr>'+
		'<tr><td colspan="3">'+
			'<table id="DXspartacus_table" cellspacing=0>'+
			optable+
			'</table>'+
		'</td></tr>'+
		'<tr><td valign="top"><a href="#" id="DXspartacus_toggleloot" title="Click to show/hide loot log">Loot/Stats:</a></td><td></td></tr>'+
		'<tr '+$c('lootlog')+'"><td valign=top>Stats:</td><td colspan="2"><span id="DXspartacus_allstats"></span></td></tr>'+
		'<tr '+$c('lootlog')+'"><td valign=top>Loot:</td><td colspan="2" id="DXspartacus_lootlog"></td></tr>'+
		'<tr><td valign="top"><a href="#" id="DXspartacus_togglearenas" title="Click to show/hide arena log">Arenas:</a></td><td></td></tr>'+
		'<tr '+$c('arenalog')+'"><td valign=top></td><td colspan="2" id="DXspartacus_arenalog"></td></tr>'+
		'<tr><td colspan="3"><span id="DXspartacus_log"></span></td></tr>'+
		'<tr><td colspan="3"><hr /></td></tr></table></div>'+
							'</div>'+
						
							'<div style="display: none;" id="DroneX_Config">'+
								'<h3 style="text-align:center;">Drone.&#12324; Config</h3>'+
								'<fieldset><legend><select id="DX_Opts"><option value="0">Job/Bandit Options</option><option value="1">Fight Options</option><option value="2">Robbing Options</option><option value="3">Spending/Restart</option><option value="4">Arena Options</option><option value="5">Misc</option></select></legend>' + 
								'<div id="DX_Job_Opts">'+
								'Do <input class="DX_Config" id="DXJPS" type="integer" value="'+DroneX.Saving.JobSpeedCounter+'" style="text-align:right;resize:none;width:10px;"> Jobs a second'+
								'<br>XP Bandit <select id="XPBanO" onChange="BanditXPCheck(this.selectedIndex)"><option value="0">Kill When Detected!</option><option value="1">Kill with 1 minute to go</option><option value="2">Kill with 2 minutes to go</option><option value="3">Kill with 3 minutes to go</option><option value="4">Skip to next job</option></select>'+
								'<br style="line-height: 30px;">'+
								'Cash Bandit <select id="CSHBanO" onChange="BanditCSHCheck(this.selectedIndex)"><option value="0">Kill When Detected!</option><option value="1">Kill with 1 minute to go</option><option value="2">Kill with 2 minutes to go</option><option value="3">Kill with 3 minutes to go</option><option value="4">Keep Jobbing Thru it</option></select>'+
								'<br style="line-height: 30px;">'+
								'Job Bandit <select id="JOBBanO" onChange="BanditJOBCheck(this.selectedIndex)"><option value="0">Kill When Detected!</option><option value="1">Wait it out!</option><option value="2">Skip to next job</option></select>'+
								'<br style="line-height: 30px;">'+
								'<input type="checkbox" id="APFC" class="DX_Config" />&nbsp;Autopost for crew when below&nbsp;<input class="DX_Config" id="CrewAmount" type="text" value="'+DroneX.Saving.CrewAmount+'" maxlength="2" style="width:15px;" /><span class="more_in"><font size="2"> Disable if you experience issues from autoposting</font></span>'+
								'<br style="line-height: 30px;">'+
								'<input type="checkbox" id="SJNC" class="DX_Config" />&nbsp;If out of crew, Skip Job?'+		
								'</div>'+ 
								'<div id="DX_Fight_Opts">'+
									'Fight in&nbsp;<select id="DXFC" onChange="FightCitySelector(this.value)"><option value="0">New York</option><option value="1">Brazil</option><option value="2">Chicago</option><option value="3">London</option><option value="4">South Africa</option><option value="5">Mexico</option></select>'+
									'<br>MW P|<input class="DX_Config" id="Dx_MWPID" type="text" value="'+DroneX.Saving.mwId+'" style="width:70px;" />'+
									'<br>Attack Speed: <input class="DX_Config" id="Dx_AttSpd" type="text" value="'+DroneX.Saving.attackspeed+'" style="width:25px;" />MS'+
									'<br>Bursts: <input class="DX_Config" id="Dx_Bursts" type="text" value="'+DroneX.Saving.Bursts+'" style="width:15px;" />'+
								'</div>'+

								'<div id="DX_Robbing_Opts">'+
									'<br style="line-height: 30px;">Marathon Stats? <input id="Dx_MarathonStats" type="checkbox" class="DX_Config"/> <a id="ResetCounters">Reset Job & Levelup Counter?</a>'+
								'</div>'+

								'<div id="DX_Spending_Opts">'+
									'Spend <select id="SpendFirst" title="Spend Which Resource First" class="DX_Config">'+
									'<option value="0">Energy</option>'+
									'<option value="1">Stamina</option>'+
									'</select> First'+
									'<br style="line-height: 30px;">Apply <select id="DxSS" onChange="SkillSpending(this.value)"><option value="0">No!</option><option value="1">Attack</option><option value="2">Defense</option><option value="3">Health</option><option value="4">Energy</option><option value="5">Stamina</option></select> Skillpoints when out of resources'+// (<a id="SpendSkillsNow">Spend Now</a>)'+
									'<br style="line-height: 30px;">Restart <input id="Dx_restart" type="checkbox" class="DX_Config"/> In: <input id="Dx_Restarttime" type="text" value="'+DroneX.Saving.RestartIn+'" maxlength="4" style="width:15px;" class="DX_Config" /> Minute(s). <span class="more_in">(Minimum: 1)</span>'+
									'<br style="line-height: 30px;">When Idle Fly to: <select id="WIFT" onChange="IdleCitySelector(this.value)"><option value="0">New York</option><option value="1">Brazil</option><option value="2">Chicago</option><option value="3">London</option><option value="4">South Africa</option><option value="5">Mexico</option></select>'+
								'</div>'+
								
								'<div id="DX_Arena_Opts">'+
									'Join:&nbsp;<select id="DXAC" onChange="ArenaSelector(this.value)"><option value="0">20 Stamina</option><option value="1">100 Stamina</option><option value="2">500 Stamina</option></select> Arenas.</br>'+
									'<span id="Arena_Switch_O"><input type="checkbox" id="DXspartacus_switch" checked class="DX_Config"/>&nbsp;Switch 500 Arenas to 100 Arenas When Below <input type="text" value="'+DroneX.Saving.arenaSAV+'" id="arena_switch_v" class="DX_Config" style="width:30px;"> Stamina</br> </span></span>'+
									'<input type="checkbox" id="DXspartacus_mobfury" class="DX_Config" title="Do 100/500 Mob-Fury Arenas instead of regular." />Mob-Fury Arenas <span class="more_in">(only 100 or 500 stamina)</span><br>'+
									'Powerattack:&nbsp;<input type="checkbox" id="DXspartacus_powerattack" checked class="DX_Config"/>&nbsp;Number of attacks:&nbsp;<input type="text" id="DXspartacus_numatt" value="'+DroneX.Saving.arenaNOA+'" title="Number of attacks to batch, maximum=3" style="width:10px;"/></br>'+
									'Target to attack:&nbsp;<select class="DX_Config" id="DXspartacus_seltarget" title="Decide target priority"><option value="lowhealth">Lowest health alive</option><option value="highhealth">Highest health</option><option value="mostpoints">Most points alive</option><option value="leastpoints">Least points alive</option><option value="mostrespect">Most respect alive</option><option value="leastrespect">Least respect alive</option><option value="allalive">Attack all alive</option><option value="leastdiff">Least difficulty</option></select></br>'+
									'Don\'t attack defense shielded players: <input type="checkbox" id="DXspartacus_skipshield" checked class="DX_Config" title="Skip def shielded players" /></br>'+
									'Don\'t attack attack shielded players: <input type="checkbox" id="DXspartacus_skipshield_a" checked class="DX_Config" title="Skip att shielded players" /></br>'+
									'Use kamikazi at the last <input type="text" value="'+DroneX.Saving.arenaBKS+'" id="DXspartacus_boostkami_s" class="DX_Config" style="width:16px;">s of the battle: <input type="checkbox" id="DXspartacus_boostkami" class="DX_Config"/></br>'+
									'Stop attacking:&nbsp;<select class="DX_Config" id="DXspartacus_stopon" title="In-arena play style"><option value="never">never (attack until stamina is gone)</option><option value="stop">now (do not attack)</option><option value="leading">when having the lead by a specific number of points</option><option value="leading3">when having the 3rd place by a specific number of points</option><option value="leading5">when having the 5th place by a specific number of points</option><option value="staminaused">when specific amount of stamina used</option><option value="staminaleft">when specific amount of stamina left</option></select><span id="show_stopon_value"> value: <input type="text" id="DXspartacus_stoponvalue" value="'+DroneX.Saving.arenaSOV+'" style="width: 40px;" /></span></br>'+
									'Do not sort player list: <input type="checkbox" id="DXspartacus_sortplayer" class="DX_Config" /></br>'+
								'</div>'+

								'<div id="DX_Misc_Opts">'+
								'Pageload Speed <input class="DX_Config" id="DXPLS" type="integer" value="'+DroneX.Saving.PageLoadSpeedCounter+'" style="text-align:right;resize:none;width:10px;"> seconds'+
								'<br style="line-height: 30px;">Use Family XP to Level? <input id="Dx_famXP" type="checkbox" class="DX_Config"/>'+
								'<br style="line-height: 30px;"><input id="Dx_StopAtLvl" type="checkbox" class="DX_Config"/> Stop at level <input class="DX_Config" id="DXSLVL" type="integer" value="'+DroneX.Saving.StopAtLvlNum+'" style="text-align:right;resize:none;width:45px;">'+	
								'<br>AutoStart? <input id="Dx_AutoStart" type="checkbox" class="DX_Config">'+	
								'<br>Heal when possible? (In NY) <input id="HWP" type="checkbox" class="DX_Config">'+
								'<br>Background <select id="BGC" onChange="BGCheck(this.selectedIndex)"><option value="0">Mexico</option><option value="1">London</option><option value="2">Hydro</option><option value="3">OfficerJAKE Special</option><option value="4">OfficerJAKE Halloween Special</option></select> (YEA SERIOUSLY!!!)'+
								'<br>Password: <input id="DXPWD" style="text-align:right;resize:none;width:30px;"> <a id="DXPWDS" class="sexy_button_new green short"><span><span>Submit</span></span></a>'+
								/*'<br style="line-height: 30px;">Adding Seconds Into Timestamp is: <a id="AddSeconds" href="#"><span id="TimeStampSeconds">' + AddSecondsText + '</span></a>'+
								'<br style="line-height: 30px;">Debug For Sim is: <a id="DebugChange" href="#"><span id="DebugGUI">' + DebugText + '</span></a>'+*/
								'</div>'+
								'</fieldset>'+
							'</div>'+
							
							'<div id="DroneX_JobSetup">'+
								'<center><a id="Show_Opt_Energy" class="sexy_button_new green short"><span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon-energy.gif"> Energy</span></span></a>&nbsp;<a id="Show_Opt_Stamina" class="sexy_button_new short red"><span><span><img src="http://mwfb.static.zynga.com/mwfb/graphics/icon_stamina_16x16_01.gif"> Stamina</span></span></a></center>'+
								'<span id="Energy_Opt" style="display:none">'+
								'<center>'+
								'Add the jobs you wish to perform...<br>'+
								'<a id="Show_Location_NY" class="sexy_button_new black short"><span><span>New York</span></span></a>&nbsp;'+
								'<a id="Show_Location_BRL" class="sexy_button_new black short"><span><span>Brazil</span></span></a>&nbsp;'+
								'<a id="Show_Location_CHI" class="sexy_button_new black short"><span><span>Chicago</span></span></a>&nbsp;'+
								'<a id="Show_Location_LON" class="sexy_button_new black short"><span><span>London</span></span></a>&nbsp;'+
								'<a id="Show_Location_SA" class="sexy_button_new black short"><span><span>South Africa</span></span></a>&nbsp;'+
								'<a id="Show_Location_MEX" class="sexy_button_new black short"><span><span>Mexico</span></span></a>&nbsp;'+
								'<a class="sexy_button_new black short orange" id="Show_Location_LT"><span><span>Limited Time</span></span></a>'+
								'</center>'+
							'<br>'+
							'<div id="Location_NY" style="display:none">'+
							'<center>'+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_2">D2</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_3">D3</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_4">D4</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_5">D5</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_6">D6</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_7">D7</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_8">D8</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_NY_9">D9</span></span></a> '+
							'</center>'+
							/*'<span id="ShowHide_NY_1">District 1</span>'+
							'<div id="NY_1" style="display:none">';
							for (i = 0; i < NYJobMap['D1'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D1'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_1_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+ */
//							'<span id="ShowHide_NY_2">District 2</span>'+
							'<div id="NY_2" style="display:none">';
							for (i = 0; i < NYJobMap['D2'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D2'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_2_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_NY_3">District 3</span>'+
							'<div id="NY_3" style="display:none">';
							for (i = 0; i < NYJobMap['D3'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D3'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_3_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_NY_4">District 4</span>'+
							'<div id="NY_4" style="display:none">';
							for (i = 0; i < NYJobMap['D4'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D4'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_4_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_NY_5">District 5</span>'+
							'<div id="NY_5" style="display:none">';
							for (i = 0; i < NYJobMap['D5'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D5'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_5_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_NY_6">District 6</span>'+
							'<div id="NY_6" style="display:none">';
							for (i = 0; i < NYJobMap['D6'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D6'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_6_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_NY_7">District 7</span>'+
							'<div id="NY_7" style="display:none">';
							for (i = 0; i < NYJobMap['D7'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D7'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_7_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_NY_8">District 8</span>'+
							'<div id="NY_8" style="display:none">';
							for (i = 0; i < NYJobMap['D8'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D8'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_8_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_NY_9">District 9</span>'+
							'<div id="NY_9" style="display:none">';
							for (i = 0; i < NYJobMap['D9'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + NYJobMap['D9'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_NYJOB" class="sexy_button_new short green"><span><span id="NY_9_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'</div>'+//end ny
							'<div id="Location_BRL" style="display:none">'+
							'<center>'+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_1">D1</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_2">D2</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_3">D3</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_4">D4</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_5">D5</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_6">D6</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_7">D7</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_BRL_8">D8</span></span></a> '+
							'</center>'+							
//							'<span id="ShowHide_BRL_1">District 1</span>'+
							'<div id="BRL_1" style="display:none">';
							for (i = 0; i < BRLJobMap['D1'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + BRLJobMap['D1'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_1_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_BRL_2">District 2</span>'+
							'<div id="BRL_2" style="display:none">';
							for (i = 0; i < BRLJobMap['D2'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + BRLJobMap['D2'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_2_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_BRL_3">District 3</span>'+
							'<div id="BRL_3" style="display:none">';
							for (i = 0; i < BRLJobMap['D3'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + BRLJobMap['D3'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_3_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_BRL_4">District 4</span>'+
							'<div id="BRL_4" style="display:none">';
							for (i = 0; i < BRLJobMap['D4'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + BRLJobMap['D4'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_4_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_BRL_5">District 5</span>'+
							'<div id="BRL_5" style="display:none">';
							for (i = 0; i < BRLJobMap['D5'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + BRLJobMap['D5'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_5_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_BRL_6">District 6</span>'+
							'<div id="BRL_6" style="display:none">';
							for (i = 0; i < BRLJobMap['D6'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + BRLJobMap['D6'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_6_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_BRL_7">District 7</span>'+
							'<div id="BRL_7" style="display:none">';
							for (i = 0; i < BRLJobMap['D7'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + BRLJobMap['D7'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_7_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_BRL_8">District 8</span>'+
							'<div id="BRL_8" style="display:none">';
							for (i = 0; i < BRLJobMap['D8'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + BRLJobMap['D8'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_BRLJOB" class="sexy_button_new short green"><span><span id="BRL_8_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'</div>'+//end brl
							'<div id="Location_CHI" style="display:none">'+
							'<center>'+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_CHI_1">D1</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_CHI_2">D2</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_CHI_3">D3</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_CHI_4">D4</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_CHI_5">D5</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_CHI_6">D6</span></span></a> '+
							'</center>'+							
//							'<span id="ShowHide_CHI_1">District 1</span>'+
							'<div id="CHI_1" style="display:none">';
							for (i = 0; i < CHIJobMap['D1'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + CHIJobMap['D1'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_CHIJobs" class="sexy_button_new short green"><span><span id="CHI_1_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_CHI_2">District 2</span>'+
							'<div id="CHI_2" style="display:none">';
							for (i = 0; i < CHIJobMap['D2'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + CHIJobMap['D2'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_CHIJobs" class="sexy_button_new short green"><span><span id="CHI_2_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_CHI_3">District 3</span>'+
							'<div id="CHI_3" style="display:none">';
							for (i = 0; i < CHIJobMap['D3'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + CHIJobMap['D3'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_CHIJobs" class="sexy_button_new short green"><span><span id="CHI_3_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_CHI_4">District 4</span>'+
							'<div id="CHI_4" style="display:none">';
							for (i = 0; i < CHIJobMap['D4'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + CHIJobMap['D4'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_CHIJobs" class="sexy_button_new short green"><span><span id="CHI_4_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_CHI_5">District 5</span>'+
							'<div id="CHI_5" style="display:none">';
							for (i = 0; i < CHIJobMap['D5'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + CHIJobMap['D5'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_CHIJobs" class="sexy_button_new short green"><span><span id="CHI_5_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_CHI_6">District 6</span>'+
							'<div id="CHI_6" style="display:none">';
							for (i = 0; i < CHIJobMap['D6'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + CHIJobMap['D6'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_CHIJobs" class="sexy_button_new short green"><span><span id="CHI_6_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'</div>'+//end CHI
							'<div id="Location_LON" style="display:none">'+
							'<center>'+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_1">D1</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_2">D2</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_3">D3</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_4">D4</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_5">D5</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_6">D6</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_7">D7</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_8">D8</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_9">D9</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_LON_10">D10</span></span></a> '+								
							'</center>'+							
//							'<span id="ShowHide_LON_1">District 1</span>'+
							'<div id="LON_1" style="display:none">';
							for (i = 0; i < LONJobMap['D1'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D1'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_1_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_2">District 2</span>'+
							'<div id="LON_2" style="display:none">';
							for (i = 0; i < LONJobMap['D2'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D2'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_2_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_3">District 3</span>'+
							'<div id="LON_3" style="display:none">';
							for (i = 0; i < LONJobMap['D3'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D3'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_3_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_4">District 4</span>'+
							'<div id="LON_4" style="display:none">';
							for (i = 0; i < LONJobMap['D4'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D4'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_4_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_5">District 5</span>'+
							'<div id="LON_5" style="display:none">';
							for (i = 0; i < LONJobMap['D5'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D5'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_5_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_6">District 6</span>'+
							'<div id="LON_6" style="display:none">';
							for (i = 0; i < LONJobMap['D6'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D6'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_6_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_7">District 7</span>'+
							'<div id="LON_7" style="display:none">';
							for (i = 0; i < LONJobMap['D7'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D7'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_7_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_8">District 8</span>'+
							'<div id="LON_8" style="display:none">';
							for (i = 0; i < LONJobMap['D8'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D8'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_8_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_9">District 9</span>'+
							'<div id="LON_9" style="display:none">';
							for (i = 0; i < LONJobMap['D9'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D9'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_9_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_LON_10">District 10</span>'+
							'<div id="LON_10" style="display:none">';
							for (i = 0; i < LONJobMap['D10'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + LONJobMap['D10'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LONJobs" class="sexy_button_new short green"><span><span id="LON_10_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'</div>'+//end LON
							'<div id="Location_SA" style="display:none">'+
							'<center>'+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_1">D1</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_2">D2</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_3">D3</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_4">D4</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_5">D5</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_6">D6</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_7">D7</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_8">D8</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_9">D9</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_SA_10">D10</span></span></a> '+								
							'</center>'+							
//							'<span id="ShowHide_SA_1">District 1</span>'+
							'<div id="SA_1" style="display:none">';
							for (i = 0; i < SAJobMap['D1'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D1'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_1_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_2">District 2</span>'+
							'<div id="SA_2" style="display:none">';
							for (i = 0; i < SAJobMap['D2'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D2'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_2_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_3">District 3</span>'+
							'<div id="SA_3" style="display:none">';
							for (i = 0; i < SAJobMap['D3'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D3'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_3_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_4">District 4</span>'+
							'<div id="SA_4" style="display:none">';
							for (i = 0; i < SAJobMap['D4'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D4'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_4_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_5">District 5</span>'+
							'<div id="SA_5" style="display:none">';
							for (i = 0; i < SAJobMap['D5'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D5'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_5_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_6">District 6</span>'+
							'<div id="SA_6" style="display:none">';
							for (i = 0; i < SAJobMap['D6'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D6'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_6_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_7">District 7</span>'+
							'<div id="SA_7" style="display:none">';
							for (i = 0; i < SAJobMap['D7'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D7'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_7_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_8">District 8</span>'+
							'<div id="SA_8" style="display:none">';
							for (i = 0; i < SAJobMap['D8'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D8'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_8_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_9">District 9</span>'+
							'<div id="SA_9" style="display:none">';
							for (i = 0; i < SAJobMap['D9'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D9'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_9_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
//							'<span id="ShowHide_SA_10">District 10</span>'+
							'<div id="SA_10" style="display:none">';
							for (i = 0; i < SAJobMap['D10'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + SAJobMap['D10'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAJobs" class="sexy_button_new short green"><span><span id="SA_10_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'</div>'+//end SA
							'<div id="Location_MEX" style="display:none">'+
							'<center>'+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_1">D1</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_2">D2</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_3">D3</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_4">D4</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_5">D5</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_6">D6</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_7">D7</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_8">D8</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_9">D9</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_10">D10</span></span></a> '+
								' <a class="sexy_button_new purple short"><span><span id="ShowHide_MEX_11">D11</span></span></a> '+								
							'</center>'+	
							'<div id="MEX_1" style="display:none">';
							for (i = 0; i < MEXJobMap['D1'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D1'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_1_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'<div id="MEX_2" style="display:none">';
							for (i = 0; i < MEXJobMap['D2'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D2'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_2_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'<div id="MEX_3" style="display:none">';
							for (i = 0; i < MEXJobMap['D3'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D3'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_3_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'<div id="MEX_4" style="display:none">';
							for (i = 0; i < MEXJobMap['D4'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D4'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_4_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							
							'<div id="MEX_5" style="display:none">';
							for (i = 0; i < MEXJobMap['D5'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D5'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_5_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							
							'<div id="MEX_6" style="display:none">';
							for (i = 0; i < MEXJobMap['D6'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D6'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_6_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							'<div id="MEX_7" style="display:none">';
							for (i = 0; i < MEXJobMap['D7'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D7'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_7_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+
							
							'<div id="MEX_8" style="display:none">';
							for (i = 0; i < MEXJobMap['D8'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D8'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_8_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+	
							'<div id="MEX_9" style="display:none">';
							for (i = 0; i < MEXJobMap['D9'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D9'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_9_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+	
							
							'<div id="MEX_10" style="display:none">';
							for (i = 0; i < MEXJobMap['D10'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D10'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_10_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+

							'<div id="MEX_11" style="display:none">';
							for (i = 0; i < MEXJobMap['D11'].length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + MEXJobMap['D11'][i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXJobs" class="sexy_button_new short green"><span><span id="MEX_11_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '</div>'+							
							'</div>'+//end MEX
							'<div id="Location_LT" style="display:none">';
							if(SecretDistrictCounter > 0){
								for (i = 0; i < SecretDistrictCounter; i++) {
									MainIndexOf += '<a class="sexy_button_new short orange" id="'+DroneX.SDMap[i].isTab+'"><span><span>'+DroneX.SDMap[i].isName+'</span></span></a> <a id="GrabSD_'+i+'" class="sexy_button_new short black" style=""><span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/action_box_icon_refresh.gif"></span></span></a><br><div id="'+DroneX.SDMap[i].isTab+'_Jobs"></div>'
								}
							}else{
								MainIndexOf += 'No Secret District(s) detected, try reloading MW!'
							}
							MainIndexOf += '</div></span>'+//end LT
							'<span id="Stamina_Opt" style="display:none">'+
							'<a class="sexy_button_new short red"><span><span> FOB Options </span></span></a>';
							for (i = 0; i < Object.keys(StamJobs)[3]; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">' + StamJobs[i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_SAFobs" class="sexy_button_new short green"><span><span id="SA_10_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							for (i = 3; i < StamJobs.length; i++) {
								MainIndexOf += '<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:670px;float:left;"><div style="margin-top:5px;">' + StamJobs[i].isName + ' <span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_MEXFobs" class="sexy_button_new short green"><span><span id="MEX_10_' + i + '">Add</span></span></a></span></div></span></li>'
							}
							MainIndexOf += '<br><br><a class="sexy_button_new short red"><span><span> Robbing </span></span></a><br>'+
							'<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">Rob In: <select id="DX_Rob_Opts"><option value="1">New York</option><option value="7">Brazil</option><option value="8">Chicago</option><option value="9">London</option><option value="10">South Africa</option><option value="11">Mexico</option></select> <span style="float:right;margin:-2px;margin-right:5px;"><a class="sexy_button_new short green" id="ADD_Rob"><span><span id="Rob_">Add</span></span></a></span></div></span></li>'+
							'<br><br><a class="sexy_button_new short red"><span><span> Fighting </span></span></a><br>'+
							'<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">Killer Kami (only option currently)<span style="float:right;margin:-2px;margin-right:5px;"><a class="sexy_button_new short green" id="ADD_Kami"><span><span id="Kami_">Add</span></span></a></span></div></span></li>'+
							'<br><br><a class="sexy_button_new short red"><span><span> Arena </span></span></a><br>'+
							'<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">Spartacus v1.28<span style="float:right;margin:-2px;margin-right:5px;"><a class="sexy_button_new short green" id="ADD_Spart"><span><span id="Spart_">Add</span></span></a></span></div></span></li>'+
							'</span>'+
							'</div>'+
						'<div style="display: none;" id="DroneX_JobList">'+
							'<center><a style="width:400px;" class="sexy_button_new short green"><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+DroneX.Imgs.EnergyIcon+'"> Energy Options </span></span></a> <a id="dragEm" class="sexy_button_new short black" style=""><span><span><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/quest/toughguy-icon.png" style="height:20px;width:20px;"></span></span></a></center>'+
							'<ul id="customjobs"></ul>'+
							/*'<center><a style="width:450px;" class="sexy_button_new short orange"><span><span><img src="'+DroneX.Imgs.EnergyIcon+'"> Backup Options </span></span></a></center>'+
							'<ul id="BackupChoice">'+
							'<li style="clear:both;list-style-type: none;height:36px;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">Currently Disabled</span></li>'+
							'</ul>'+*/
							'<center><a style="width:450px;" class="sexy_button_new short red"><span><span><img src="'+DroneX.Imgs.StaminaIcon+'"> Stamina Options </span></span></a></center>'+
							'<ul id="customStaminaChoice"></ul>'+
							'Remove Energy/Stamina Jobs when out of Cash or consumables? <input id="Dx_RemoveJob" type="checkbox" class="DX_Config"/>'+
							'</div>'+
							 '<div style="display: none; text-size:15px;" id="DroneX_ChangeLog">'+
								ChangeLogInfoz+
							'</div>'+
					'</div>'+
					'<span id="lastspan" class="energy_highlight" style="position:absolute; left: 595px;"><img title="Made & tested on FireFox" style="width:20px;height:20px;" src="http://upload.wikimedia.org/wikipedia/en/e/e3/Firefox-logo.svg"><b>Powered by $.Click()</b></span>'+				
					'</div>'+
				'</div>'+
			'</div><br style="clear:both;">';
				
	function LoadDroneXMain() {
		$('#DroneX_MainTab').removeClass('DroneX_TabInActive').addClass('DroneX_TabActive');
		$('#DroneX_ConfigTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');	
		$('#DroneX_JobSetupTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_JobListTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_ChangeLogTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');		
		$('#DroneX_Config').css('display','none');
		$('#DroneX_JobSetup').css('display','none');
		$('#DroneX_JobList').css('display','none');
		$('#DroneX_ChangeLog').css('display','none');
		$('#DroneX_Main').show();
	}

	function LoadDroneXConfig() {
		$('#DroneX_MainTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_ConfigTab').removeClass('DroneX_TabInActive').addClass('DroneX_TabActive');		
		$('#DroneX_JobSetupTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_JobListTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_ChangeLogTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_Main').css('display','none');
		$('#DroneX_JobSetup').css('display','none');
		$('#DroneX_JobList').css('display','none');
		$('#DroneX_ChangeLog').css('display','none');
		$('#DroneX_Config').show();
	}
	
	function LoadDroneXJobSetup() {
		$('#DroneX_MainTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_ConfigTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_JobSetupTab').removeClass('DroneX_TabInActive').addClass('DroneX_TabActive');	
		$('#DroneX_JobListTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_ChangeLogTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_Main').css('display','none');
		$('#DroneX_Config').css('display','none');
		$('#DroneX_JobList').css('display','none');
		$('#DroneX_ChangeLog').css('display','none');
		$('#DroneX_JobSetup').show();
	}
	
	function LoadDroneXJobList() {
		$('#DroneX_MainTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_ConfigTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_JobSetupTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_JobListTab').removeClass('DroneX_TabInActive').addClass('DroneX_TabActive');
		$('#DroneX_ChangeLogTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');		
		$('#DroneX_Main').css('display','none');
		$('#DroneX_Config').css('display','none');
		$('#DroneX_JobSetup').css('display','none');
		$('#DroneX_ChangeLog').css('display','none');
		$('#DroneX_JobList').show();
	}
	
	function LoadDroneXChangeLog() {
		$('#DroneX_MainTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_ConfigTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_JobSetupTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_JobListTab').removeClass('DroneX_TabActive').addClass('DroneX_TabInActive');
		$('#DroneX_ChangeLogTab').removeClass('DroneX_TabInActive').addClass('DroneX_TabActive');
		$('#DroneX_Main').css('display','none');
		$('#DroneX_Config').css('display','none');
		$('#DroneX_JobSetup').css('display','none');
		$('#DroneX_JobList').css('display','none');
		$('#DroneX_ChangeLog').show();
	}
	
	var powerups = {
		1:{name:"Stamina Refill",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_staminarefill_01.png"},
		2:{name:"Arena Health Refill",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_arenahealthrefill_01.png"},
		3:{name:"Meta Flair",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_quartflair_01.png"},
		4:{name:"Pain Killer",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_painkiller_01.png"},
		5:{name:"Kamikaze",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_suckerpunch_01.png"},
		6:{name:"Drained",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_drained_02.png"},
		7:{name:"Reflector",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_reflector_01.png"},
		//8:{name:"Freeze",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_freeze_01.png"}
		//9:{name:"Dual Strike",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_dualstrike_01.png"}
		10:{name:"Tri-Rage",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_tri-rage_01.png"},
		//11:{name:"Dominade",pic:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/big_item_dominade_01.png"}
	};

	var difficulty = [
		'Easy',
		'Normal',
		'Hard'
	];

	var r_difficulty = {
		'Easy':0,
		'Normal':1,
		'Hard':2
	};
			
	create_div();
		
	$('#stop').click(function(){
		if(DroneX.isRunning){
			$('#stop').html('<span><span>GO!!!!</span></span>');
			$(this).addClass('green');
			$(this).removeClass('red');			
			DroneX.isRunning = false;
			log('DroneX Stopped...');
		}else{
			$('#stop').html('<span><span>Stop!</span></span>');
			log('Starting..');
			$(this).addClass('red');
			$(this).removeClass('green');
			DroneX.isRunning = true;
			setTimeout(function(){grabInfoz();},1000);
		}
	});

	$('a[id^="Show_Location_"]').live('click', function(){
		if(document.getElementById('Location_'+$(this).attr('id').split('_')[2]).style.display !== 'none'){
			$('a[id^="Show_Location_"]').removeClass('white').addClass('black');
			$('div[id^="Location_"]').hide();
			return;
		}else{
			$('div[id^="Location_"]').hide();
			$('a[id^="Show_Location_"]').removeClass('white').addClass('black');
			if($(this).attr('id').split('_')[2] !== 'LT'){
				$('#Show_Location_'+$(this).attr('id').split('_')[2]).addClass('white');
			}
			$('#Location_'+$(this).attr('id').split('_')[2]).show();
		}
	})
	
	$('a[id^="Show_Opt_"]').live('click', function(){
		if($('#'+$(this).attr('id').split('_')[2]+'_Opt').css('display') !== 'none'){
			$('#'+$(this).attr('id').split('_')[2]+'_Opt').hide();
			return;
		}else{
			$("span[id$='_Opt']").hide();
//			$('span[id^="_Opt"]').hide();
			$('#'+$(this).attr('id').split('_')[2]+'_Opt').show();
		}
	})
	
	$('span[id^="ShowHide_"]').live('click', function(){
		if(document.getElementById($(this).attr('id').split('_')[1]+'_'+$(this).attr('id').split('_')[2]).style.display !== 'none'){
			$('#'+$(this).attr('id').split('_')[1]+'_'+$(this).attr('id').split('_')[2]).hide();
		}else{
			$('div[id^="NY_"]').hide();
			$('div[id^="BRL_"]').hide();
			$('div[id^="CHI_"]').hide();
			$('div[id^="LON_"]').hide();
			$('div[id^="SA_"]').hide();
			$('div[id^="MEX_"]').hide();
			$('#'+$(this).attr('id').split('_')[1]+'_'+$(this).attr('id').split('_')[2]).show();
		}
	})
	
	$('a[id^="GrabSD_"]').live('click', function(){
		var grabbedID = $(this).attr('id').split('_')[1];
//		making an array for it was to hard, might come back to it tho
		document.getElementById(DroneX.SDMap[grabbedID].isTab+'_Jobs').innerHTML = '';
		AjxRequest('xw_controller=travel&xw_action=travel&from=job&destination='+DroneX.SDMap[$(this).attr('id').split('_')[1]].isCity+'&tab='+DroneX.SDMap[$(this).attr('id').split('_')[1]].isTab,function(page){
			$(page).find('.job').each(function(index){
				var GetName = $(this).find('h4').text().trim();
				var energy = $(this).find('.uses.clearfix').find('.energy').attr('current_value');
				var experience = $(this).find('.pays.clearfix').find('.experience').attr('current_value');
				var link = $(this).find('a[id^="btn_dojob_"]').attr('href');
				var jobidz = /job=(\d+)/.exec(link)[1];
				$('#'+DroneX.SDMap[grabbedID].isTab+'_Jobs').append('<li style="clear:both;list-style-type: none;"><span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 30px;width:524px;float:left;"><div style="margin-top:5px;">' + GetName + ' ('+(experience/energy).toFixed(3)+')<span style="float:right;margin:-2px;margin-right:5px;"><a id="ADD_LTDJobs" class="sexy_button_new short green"><span><span id="LTD_'+DroneX.SDMap[grabbedID].isCity+'_'+DroneX.SDMap[grabbedID].isTab+'_' + jobidz + '">Add</span></span></a></span></div></span></li>')
			});
//			logit(JSON.stringify(DroneX.SD, null, 0))
		});
	})

	$('#dragEm').live('click', function(){
		if(SortLists){
			$('#customjobs').sortable();
			$('#customjobs').disableSelection();	
			$('#customStaminaChoice').sortable();
			$('#customStaminaChoice').disableSelection();
			$(this).removeClass('black').addClass('red');
			SortLists = false;
		}else{
			$(this).removeClass('red').addClass('black');
			$('#customjobs').sortable('destroy');
			$('#customjobs').disableSelection('destroy');
			$('#customStaminaChoice').sortable('destroy');
			$('#customStaminaChoice').disableSelection('destroy');
			SortLists = true;
		}
	});
	
	$('#DXPWDS').live('click', function(){
		$('#DXPWD').val(function(){
			if(this.value == 'HMF' && !DroneX.isRunning){
				$("#DroneX_JobSetupTab .DroneX_TabMiddle img:last-child").remove();
				$("#DroneX_JobListTab .DroneX_TabMiddle img:last-child").remove();
				$("#DroneX_JobSetupTab").attr("onclick","LoadDroneXJobSetup()");
				$("#DroneX_JobListTab").attr("onclick","LoadDroneXJobList()");
				$('#start').show();
				$('#stop').hide();
				DroneX.isFirstLoad = true;
				DroneX.JobMap = new Array();
				DroneX.StamMap = new Array();
				this.value = 1;
				$('.clearitem').each(function(){
					this.click();
				})
				document.getElementById('JobList').innerHTML = '';
				document.getElementById('ActiveJob').innerHTML = '';
			}
		})
	});

	//Save config changes!
//	$("input.DX_Config:checkbox, input.DX_Config:text, .DX_Config:input").change(function(){	
	$(".DX_Config:input").change(function(){
		logit('saving errthing')
		DroneX.Saving.StamFirst = $('#SpendFirst').prop("selectedIndex");
		DroneX.Saving.CrewAmount = $('#CrewAmount').val();
		if (isNaN(parseInt(DroneX.Saving.CrewAmount)) || parseInt(DroneX.Saving.CrewAmount) > 32 || parseInt(DroneX.Saving.CrewAmount) < 1) {
			DroneX.Saving.CrewAmount = 18;
			$('#CrewAmount').val(18);
		}
		DroneX.Saving.PageLoadSpeedCounter = $('#DXPLS').val();
		if (isNaN(parseInt(DroneX.Saving.PageLoadSpeedCounter)) || parseInt(DroneX.Saving.PageLoadSpeedCounter) > 100 || parseInt(DroneX.Saving.PageLoadSpeedCounter) < 1) {
			DroneX.Saving.PageLoadSpeedCounter = 3;
			$('#DXPLS').val(3);
		}
		DroneX.Saving.PageLoadSpeed = DroneX.Saving.PageLoadSpeedCounter*1000;
		DroneX.Saving.RestartIn = $('#Dx_Restarttime').val();
		if (isNaN(parseInt(DroneX.Saving.RestartIn)) || parseInt(DroneX.Saving.RestartIn) < 1) {
			DroneX.Saving.RestartIn = 5;
			$('#Dx_Restarttime').val(5);
		}
		DroneX.Saving.JobSpeedCounter = $('#DXJPS').val();
		if(isNaN(parseInt(DroneX.Saving.JobSpeedCounter)) || parseInt(DroneX.Saving.JobSpeedCounter) < 1 || parseInt(DroneX.Saving.JobSpeedCounter) > 4) {
			DroneX.Saving.JobSpeedCounter = 2;
			$('#DXJPS').val(2);
		}
		DroneX.Saving.JobSpeed = parseInt(Math.floor(1000/DroneX.Saving.JobSpeedCounter));
		DroneX.Saving.mwId = $('#Dx_MWPID').val();
		if(isNaN(parseInt(DroneX.Saving.mwId))) {
			DroneX.Saving.mwId = 0;
			$('#Dx_MWPID').val(0);
		}
		DroneX.Saving.attackspeed = $('#Dx_AttSpd').val();
		if(isNaN(parseInt(DroneX.Saving.attackspeed)) || parseInt(DroneX.Saving.attackspeed) < 333 || parseInt(DroneX.Saving.attackspeed) > 5000) {
			DroneX.Saving.attackspeed = 1000;
			$('#Dx_AttSpd').val(1000);
		}
		DroneX.Saving.Bursts = $('#Dx_Bursts').val();
		if(isNaN(parseInt(DroneX.Saving.Bursts)) || parseInt(DroneX.Saving.Bursts) < 1 || parseInt(DroneX.Saving.Bursts) > 4) {
			DroneX.Saving.Bursts = 1;
			$('#Dx_Bursts').val(1);
		}
		if (document.getElementById("Dx_AutoStart").checked) {
			DroneX.Saving.AutoStart = true;
		}else {
			DroneX.Saving.AutoStart = false;
		}
		if (document.getElementById("HWP").checked) {
			DroneX.Saving.HWP = true;
			clearTimeout(HealOn);
			doHeal();
		}else {
			DroneX.Saving.HWP = false;
			clearTimeout(HealOn);
		}
		if (document.getElementById("APFC").checked) {
			DroneX.Saving.AutopostingCrew = true;
		}else {
			DroneX.Saving.AutopostingCrew = false;
		}
		if (document.getElementById("SJNC").checked) {
			DroneX.Saving.Skippy = true;
		}else {
			DroneX.Saving.Skippy = false;
		}
		if (document.getElementById("Dx_restart").checked) {
			DroneX.Saving.Restart = true;
		}else{
			DroneX.Saving.Restart = false;
		}
		if (document.getElementById("Dx_famXP").checked) {
			DroneX.Saving.FamXP = true;
		}else{
			DroneX.Saving.FamXP = false;
		}
		if (document.getElementById("Dx_RemoveJob").checked){
			DroneX.Saving.RemoveJobs = true;
		}else {
			DroneX.Saving.RemoveJobs = false;
		}
		if (document.getElementById("Dx_MarathonStats").checked){
			DroneX.Saving.MarathonStat = true;
		}else {
			DroneX.Saving.MarathonStat = false;
		}
		if (document.getElementById("Dx_StopAtLvl").checked){
			DroneX.Saving.StopAtLvl = true;
		}else {
			DroneX.Saving.StopAtLvl = false;
		}
		DroneX.Saving.StopAtLvlNum = $('#DXSLVL').val();
		if (isNaN(parseInt(DroneX.Saving.StopAtLvlNum)) || parseInt(DroneX.Saving.StopAtLvlNum) < 0) {
			DroneX.Saving.StopAtLvlNum = $('#user_level').text();
			$('#DXSLVL').val(DroneX.Saving.StopAtLvlNum);
		}
		if (document.getElementById("DXspartacus_switch").checked) {
			DroneX.Saving.arenaSA = true;
		}else{
			DroneX.Saving.arenaSA = false;
		}
		if (document.getElementById("DXspartacus_mobfury").checked) {
			DroneX.Saving.arenaMF = true;
		}else{
			DroneX.Saving.arenaMF = false;
		}
		if (document.getElementById("DXspartacus_powerattack").checked) {
			DroneX.Saving.arenaPA = true;
		}else{
			DroneX.Saving.arenaPA = false;
		}
		if (document.getElementById("DXspartacus_skipshield").checked) {
			DroneX.Saving.arenaSS = true;
		}else{
			DroneX.Saving.arenaSS = false;
		}
		if (document.getElementById("DXspartacus_skipshield_a").checked) {
			DroneX.Saving.arenaSSA = true;
		}else{
			DroneX.Saving.arenaSSA = false;
		}
		if (document.getElementById("DXspartacus_boostkami").checked) {
			DroneX.Saving.arenaBK = true;
		}else{
			DroneX.Saving.arenaBK = false;
		}
		if (document.getElementById("DXspartacus_sortplayer").checked) {
			DroneX.Saving.arenaSP = true;
		}else{
			DroneX.Saving.arenaSP = false;
		}
		if(document.getElementById("DXspartacus_stopon").selectedIndex > 1) {
			$('#show_stopon_value').show();
		} else {
			$('#show_stopon_value').hide();
		}
		writeSettings();
	});
			
	$('#ADD_NYJOB, #ADD_BRLJOB, #ADD_CHIJobs, #ADD_LONJobs, #ADD_SAJobs, #ADD_MEXJobs, #ADD_LTDJobs').live('click', function(){
//		if($('ul#customjobs li:contains("'+$(this).parent().parent().text()+'")').length > 0) {
		if($('ul#customjobs li').children().children().children().attr('id') == $(this).children().children().attr('id')) {
				$(this).removeClass('red').addClass('green');
				$(this).children().children().text('Add');
				$('ul#customjobs li:contains("'+$(this).parent().parent().text().slice(0,-3)+'")').remove();
				return;
		} 
		$('#customjobs').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">'+$(this).parent().parent().text().slice(0,-3)+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="'+$(this).children().children().attr('id')+'">X</a></span></span><a title="Add/Remove Energy Options" id="JobEnergyTill"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="margin:7px;"></a><a title="Add/Remove Ratio Options" id="JobRatios"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/target_daily_take_icon.png" style="margin:4px;"></a><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:330px;float:left;">Change to next job when energy is under:<input type="integer" style="resize:none;width:50px;" value="100000"></span><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:291px;float:left;">Change to next job when ratio is under:<input type="integer" style="resize:none;width:30px;" value="2.27"></span>'));
		$(this).removeClass('green').addClass('red');
		$(this).children().children().text('Remove It');
	});

	$('#ADD_SAFobs').live('click', function(){
		try{
			if($('ul#customStaminaChoice li').children().children().children().attr('id').substring(6) == $(this).children().children().attr('id')) {
					$(this).removeClass('red').addClass('green');
					$(this).children().children().text('Add');
					$('ul#customStaminaChoice li:contains("'+$(this).parent().parent().text().slice(0,-3)+'")').remove();
					return;
			}
		}catch(firstrun){}
		$('#customStaminaChoice').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">'+$(this).parent().parent().text().slice(0,-3)+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="SAFOB_'+$(this).children().children().attr('id')+'">X</a></span></span>'));
		$(this).removeClass('green').addClass('red');
		$(this).children().children().text('Remove It');
	});
	
	$('#ADD_MEXFobs').live('click', function(){
		try{
			if($('ul#customStaminaChoice li').children().children().children().attr('id').substring(6) == $(this).children().children().attr('id')) {
				$(this).removeClass('red').addClass('green');
				$(this).children().children().text('Add');
				$('ul#customStaminaChoice li:contains("'+$(this).parent().parent().text().slice(0,-3)+'")').remove();
				return;
			}
		}catch(firstrun){}
		$('#customStaminaChoice').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">'+$(this).parent().parent().text().slice(0,-3)+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="MEXFOB_'+$(this).children().children().attr('id')+'">X</a></span></span>'));
		$(this).removeClass('green').addClass('red');
		$(this).children().children().text('Remove It');
	});	
	
	$('#ADD_Rob').live('click', function(){
		try{		
			if($('ul#customStaminaChoice li a[id*="ROB_"]').length > 0) {
					$(this).removeClass('red').addClass('green');
					$(this).children().children().text('Add');
					$('ul#customStaminaChoice li:contains("Rob In")').remove();
					return;
			}
		}catch(firstrun){}
		$('#customStaminaChoice').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">Rob In '+$("#DX_Rob_Opts > option:selected").text()+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="ROB_'+$("#DX_Rob_Opts > option:selected").val()+'">X</a></span></span>'));
		DroneX.Saving.RobWhere = $('#DX_Rob_Opts').prop("selectedIndex");
		$(this).removeClass('green').addClass('red');
		$(this).children().children().text('Remove It');
	});
	
	$('#ADD_Kami').live('click', function(){
		try{		
			if($('ul#customStaminaChoice li a[id*="Kami_"]').length > 0) {
					$(this).removeClass('red').addClass('green');
					$(this).children().children().text('Add');
					$('ul#customStaminaChoice li:contains("Kami")').remove();
					return;
			}
		}catch(firstrun){}
		$('#customStaminaChoice').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">Killer Kami<span style="float:right;margin:3px;"><a href="#" class="clearitem" id="Kami_">X</a></span></span>'));
		$(this).removeClass('green').addClass('red');
		$(this).children().children().text('Remove It');
	});
	
	$('#ADD_Spart').live('click', function(){
		try{		
			if($('ul#customStaminaChoice li a[id*="Spart_"]').length > 0) {
					$(this).removeClass('red').addClass('green');
					$(this).children().children().text('Add');
					$('ul#customStaminaChoice li:contains("Spartacus")').remove();
					return;
			}
		}catch(firstrun){}
		$('#customStaminaChoice').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">Spartacus v1.28<span style="float:right;margin:3px;"><a href="#" class="clearitem" id="Spart_">X</a></span></span>'));
		$(this).removeClass('green').addClass('red');
		$(this).children().children().text('Remove It');
	});
	
	
	
	$('.clearitem').live('click', function(){
		if($(this).attr('id').slice(0,-7) == 'SAFOB_'){
			$('#ADD_SAFobs #'+$(this).attr('id').substring(6)).parent().parent().removeClass('red').addClass('green');
			$('#ADD_SAFobs #'+$(this).attr('id').substring(6)).text('Add');
		}else if($(this).attr('id').slice(0,-7) == 'MEXFOB_'){
			$('#ADD_MEXFobs #'+$(this).attr('id').substring(6)).parent().parent().removeClass('red').addClass('green');
			$('#ADD_MEXFobs #'+$(this).attr('id').substring(6)).text('Add');
		}else if($(this).attr('id').slice(0,-1) == 'ROB_'){
			$('#ADD_Rob').removeClass('red').addClass('green');
			$('#ADD_Rob').children().children().text('Add');		
		}else if($(this).attr('id') == 'Kami'){
			$('#ADD_Kami').removeClass('red').addClass('green');
			$('#ADD_Kami').children().children().text('Add');		
		}else if($(this).attr('id') == 'Spartacus'){
			$('#ADD_Spart').removeClass('red').addClass('green');
			$('#ADD_Spart').children().children().text('Add');		
		}else{
			$("#"+$(this).attr('id')).parent().parent().removeClass('red').addClass('green');
			$("#"+$(this).attr('id')).text('Add');
		}
		$(this).parent().parent().parent().next("span").remove();		
		$(this).parent().parent().parent().remove();	
		return false;
	});
		
	$("#JobEnergyTill").live('click', function(){
		$(this).parent().children().last().hide();
		$(this).parent().children().last().prev().toggle();
		return false;
	});
		
	$("#JobRatios").live('click', function(){
		$(this).parent().children().last().prev().hide();
		$(this).parent().children().last().toggle();
		return false;
	});
	
	$("#start").live('click', function(){
		$('#DxAS').hide();
		clearTimeout(ClickGo);
		DroneX.Saving.isHiding = new Array();
		$('#customjobs li a').each(function(){
			if($(this).attr('id') == 'JobRatios' || $(this).attr('id') == 'JobEnergyTill'){
				return true;
			}
			var Ratioing;//$(this).parent().children().last().prev()
			var RatioingJobValue = '0.00';
			var NRGSwitch;
			var NRGSwitchValue;
			if($(this).parent().parent().parent().children().last().css('display') == 'none'){ //Ratioing is off
				Ratioing = false;
			}else{
				Ratioing = true;
				var jrv = parseFloat($(this).parent().parent().parent().children().last().children('input').val());
				RatioingJobValue = jrv.toPrecision(3);
			}
			if($(this).parent().parent().parent().children().last().prev().css('display') == 'none'){ //NRGSwitch is off
				NRGSwitch = false;
			}else{
				NRGSwitch = true;
				NRGSwitchValue = parseInt($(this).parent().parent().parent().children().last().prev().children('input').val());
			}
			var new_job;
//			DroneX.Settings.isHiding.push($(this).attr('id')); //puts ID in the save arrary! SA_1_0 LTD_134_1043
//			logit(JSON.stringify(DroneX.Saving.isHiding, null, 0))
			var info = $(this).attr('id').split('_');
			var city = info[0];
			var district = 'D'+parseInt(info[1]);
			var job = parseInt(info[2]);
			if(city == 'NY' && district == 'D1'){
				var extra = (NYJobMap[district][job].isTheXP/NYJobMap[district][job].isCost).toFixed(3);
				new_job = {isName:NYJobMap[district][job].isName, isJobID:NYJobMap[district][job].isJobID, isTab:NYJobMap[district][job].isTab, isCity:NYJobMap[district][job].isCity, isCost:NYJobMap[district][job].isCost, isOldCity: false, isFlashNY: true, isUsingButton: false, isCost: NYJobMap[district][job].isCost, isTheXP: NYJobMap[district][job].isTheXP, isEnabled: true, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue, isRationOn:Ratioing, RatioVal:RatioingJobValue, isRatio: extra, isSkipping:false};
			}else if(city == 'NY'){
				new_job = {isName:NYJobMap[district][job].isName, isJobID:NYJobMap[district][job].isJobID, isTab:NYJobMap[district][job].isTab, isCity:NYJobMap[district][job].isCity, isOldCity: true, isFlashNY: false, isUsingButton: false, isCost: 0, isTheXP: 0, isEnabled: true, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue, isRationOn:Ratioing, RatioVal:RatioingJobValue, isRatio: 0, isSkipping:false};
			}else if(city == 'BRL'||city == 7){
				new_job = {isName:BRLJobMap[district][job].isName, isJobID:BRLJobMap[district][job].isJobID, isTab:BRLJobMap[district][job].isTab, isCity:BRLJobMap[district][job].isCity, isOldCity: false, isFlashNY: false, isUsingButton: true, isCost: 0, isTheXP: 0, isEnabled: true, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue, isRationOn:Ratioing, RatioVal:RatioingJobValue, isRatio: 0, isSkipping:false};
			}else if(city == 'CHI'||city == 8){
				new_job = {isName:CHIJobMap[district][job].isName, isJobID:CHIJobMap[district][job].isJobID, isTab:CHIJobMap[district][job].isTab, isCity:CHIJobMap[district][job].isCity, isOldCity: false, isFlashNY: false, isUsingButton: true, isCost: 0, isTheXP: 0, isEnabled: true, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue, isRationOn:Ratioing, RatioVal:RatioingJobValue, isRatio: 0, isSkipping:false};
			}else if(city == 'LON'||city == 9){
				new_job = {isName:LONJobMap[district][job].isName, isJobID:LONJobMap[district][job].isJobID, isTab:LONJobMap[district][job].isTab, isCity:LONJobMap[district][job].isCity, isOldCity: false, isFlashNY: false, isUsingButton: true, isCost: 0, isTheXP: 0, isEnabled: true, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue, isRationOn:Ratioing, RatioVal:RatioingJobValue, isRatio: 0, isSkipping:false};
			}else if(city == 'SA'||city == 10){
				new_job = {isName:SAJobMap[district][job].isName, isJobID:SAJobMap[district][job].isJobID, isTab:SAJobMap[district][job].isTab, isCity:SAJobMap[district][job].isCity, isOldCity: false, isFlashNY: false, isUsingButton: true, isCost: 0, isTheXP: 0, isEnabled: true, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue, isRationOn:Ratioing, RatioVal:RatioingJobValue, isRatio: 0, isSkipping:false};
			}else if(city == 'MEX'||city == 11){
				new_job = {isName:MEXJobMap[district][job].isName, isJobID:MEXJobMap[district][job].isJobID, isTab:MEXJobMap[district][job].isTab, isCity:MEXJobMap[district][job].isCity, isOldCity: false, isFlashNY: false, isUsingButton: true, isCost: 0, isTheXP: 0, isEnabled: true, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue, isRationOn:Ratioing, RatioVal:RatioingJobValue, isRatio: 0, isSkipping:false};
			}else if(city == 'LTD'){
				var myparent = $('#customjobs #'+$(this).attr('id')).parent()[0].previousSibling;
				var ltdname = $(myparent).text();
				new_job = {isName:ltdname, isJobID:info[3], isTab:info[2], isCity:info[1], isOldCity: false, isFlashNY: false, isUsingButton: true, isLTD: true, isCost: 0, isTheXP: 0, isEnabled: true, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue, isRationOn:Ratioing, RatioVal:RatioingJobValue, isRatio: 0, isSkipping:false};
			}
			var saving = {isInfo:$(this).attr('id'), isRatioOn: Ratioing, isRatioVal: RatioingJobValue, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue};
			if(city == 'LTD'){
				var myparent = $('#customjobs #'+$(this).attr('id')).parent()[0].previousSibling;
				var ltdname = $(myparent).text();
				saving = {isCheatName:ltdname, isInfo:$(this).attr('id'), isRatioOn: Ratioing, isRatioVal: RatioingJobValue, isNRGSwitchOn:NRGSwitch, isNRGValue:NRGSwitchValue};
			}
			DroneX.Saving.isHiding.push(saving);
			DroneX.JobMap.push(new_job);
		})
		if(DroneX.JobMap.length < 1){
			alert('You must add at least one job');
			return;
		}		
		DroneX.JobMap[DroneX.JobMap.length-1].isRationOn = false;
		DroneX.JobMap[DroneX.JobMap.length-1].isNRGSwitchOn = false;
		$('#customStaminaChoice li a').each(function(){
//			DroneX.Settings.isHiding.push($(this).attr('id'));  //puts ID in the save arrary!
			var new_job;
			var saving = {isInfo:$(this).attr('id')};
			DroneX.Saving.isHiding.push(saving);
			var info = $(this).attr('id').split('_');
			var InfoZ = parseInt(info[3]);
			if(isNaN(InfoZ)){
				if($(this).attr('id') == "Kami_"){
					new_job = {
							isName:'Killer Kami', isCity:DroneX.Saving.FightCity, isCost:75, isTab:"fight", isMastered:DroneX.Imgs.FamilyIcon, isRobbing:false, isArena:false
					};
				}else if($(this).attr('id') == "Spart_"){
					var arenaval;
					if(parseInt($('#DXAC').val()) == 0){
						arenaval = 20;
					}else if(parseInt($('#DXAC').val()) == 1){
						arenaval = 100;
					}else{
						arenaval = 500;
					}
					new_job = {
							isName:'Spartacus v1.28', isCity:DroneX.Saving.FightCity, isCost:arenaval, isTab:"arena", isMastered:DroneX.Imgs.FamilyIcon, isRobbing:false, isArena:true
					};
				}else{
					var myparent = $('#customStaminaChoice #'+$(this).attr('id')).parent()[0].previousSibling;
					var robname = $(myparent).text();
					new_job = {
						isName:robname, isCity:info[1], isCost:25, isTab:"robbing", isMastered:DroneX.Imgs.FamilyIcon, isRobbing:true, isArena:false
					};
				}
			}else{
				new_job = {
					isName:StamJobs[InfoZ].isName, isJobID:StamJobs[InfoZ].isJobID, isCity:StamJobs[InfoZ].isCity, isCost:StamJobs[InfoZ].isCost, isTab:StamJobs[InfoZ].isTab, isTheXP:StamJobs[InfoZ].isTheXP, isRobbing:false, isMastered:DroneX.Imgs.RubyStar, isArena:false
				};
			}
			DroneX.StamMap.push(new_job);
//			logit(JSON.stringify(DroneX.StamMap, null, 0))
		});
		if(DroneX.StamMap.length < 1){
			alert('You must add at least one stamina job');
			return;
		}		
		$('#DroneX_MainTab').click();
		$('#DroneX_JobSetupTab .DroneX_TabMiddle').prepend(' <img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/item_treasure_chest_key.gif" style="height:18px;width:18px;text-align:center;margin:-3px;">');
		$('#DroneX_JobListTab .DroneX_TabMiddle').prepend(' <img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/item_treasure_chest_key.gif" style="height:18px;width:18px;text-align:center;margin:-3px;">');
		$("#DroneX_JobSetupTab").attr("onclick","");
		$("#DroneX_JobListTab").attr("onclick","");
		$('#start').hide();
		$('#stop').show();
//		$("#DX_Opts option[value=4]").removeAttr('disabled');
		writeSettings();
		setTimeout(function(){grabInfoz();},1000);
		return false;
	});

	BGCheck = function(n){
		if (DroneX.Saving.BG != n){
			DroneX.Saving.BG = n;
			writeSettings();
		}
		switch(parseInt(n)){
			case 0:
			document.getElementById('BGS').style.background = 'url(https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/empire/mexico_hp_bg.jpg)  no-repeat'; 
			break;
			case 1:
			document.getElementById('BGS').style.background = 'url(https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/empire/london_hp_bg.png)  no-repeat'; 
			break;
			case 2:
			document.getElementById('BGS').style.background = 'url(https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/crafters_choice/hellish_hydraulics/popup_bg.jpg)  no-repeat'; 
			document.getElementById('BGS').style.backgroundSize = '100% 100%';
			break;
			case 3:
			document.getElementById('BGS').style.background = 'url(http://file1.hpage.com/004925/76/bilder/wallpaper-2.jpg)  no-repeat'; 
			document.getElementById('BGS').style.backgroundSize = '100% 100%';
			break;
			case 4:
			document.getElementById('BGS').style.background = 'url(http://file1.hpage.com/004925/76/bilder/wallpaper-1.jpg)  no-repeat'; 
			document.getElementById('BGS').style.backgroundSize = '100% 100%';
			break;
		}
	};
	
	BanditXPCheck = function(n){
		if (DroneX.Saving.BanditXPCheck != n){
			DroneX.Saving.BanditXPCheck = n;
			writeSettings();
		}
		switch(parseInt(n)){
			case 0:
			DroneX.Bandits.BanditGamblerXP = false;
			DroneX.Bandits.SkippyXP = false;
			DroneX.Bandits.BanditElapsedTimerXP = 4;
			break;
			case 1:
			DroneX.Bandits.BanditGamblerXP = true;
			DroneX.Bandits.SkippyXP = false;
			DroneX.Bandits.BanditElapsedTimerXP = 1;
			break;
			case 2:
			DroneX.Bandits.BanditGamblerXP = true;
			DroneX.Bandits.SkippyXP = false;
			DroneX.Bandits.BanditElapsedTimerXP = 2;
			break;
			case 3:
			DroneX.Bandits.BanditGamblerXP = true;
			DroneX.Bandits.SkippyXP = false;
			DroneX.Bandits.BanditElapsedTimerXP = 3;
			break;
			case 4:
			DroneX.Bandits.BanditGamblerXP = false;
			DroneX.Bandits.BanditElapsedTimerXP = 4;
			DroneX.Bandits.SkippyXP = true;
			break;
		}
	};
	
	BanditCSHCheck = function(n){
		if (DroneX.Saving.BanditCSHCheck != n){
			DroneX.Saving.BanditCSHCheck = n;
			writeSettings();
		}
		switch(parseInt(n)){
			case 0:
			DroneX.Bandits.BanditGamblerCSH = false;
			DroneX.Bandits.lolzatcash = false;
			DroneX.Bandits.BanditElapsedTimerCash = 4;
			break;
			case 1:
			DroneX.Bandits.BanditGamblerCSH = true;
			DroneX.Bandits.lolzatcash = false;
			DroneX.Bandits.BanditElapsedTimerCash = 1;
			break;
			case 2:
			DroneX.Bandits.BanditGamblerCSH = true;
			DroneX.Bandits.lolzatcash = false;
			DroneX.Bandits.BanditElapsedTimerCash = 2;
			break;
			case 3:
			DroneX.Bandits.BanditGamblerCSH = true;
			DroneX.Bandits.lolzatcash = false;
			DroneX.Bandits.BanditElapsedTimerCash = 3;
			break;
			case 4:
			DroneX.Bandits.BanditGamblerCSH = false;
			DroneX.Bandits.lolzatcash = true;
			DroneX.Bandits.BanditElapsedTimerCash = 4;
			break;
		}
	};
	
	BanditJOBCheck = function(n){
		if (DroneX.Saving.BanditJOBCheck != n){
			DroneX.Saving.BanditJOBCheck = n;
			writeSettings();
		}
		switch(parseInt(n)){
			case 0:
			DroneX.Bandits.BanditJob = true;
			DroneX.Bandits.SkippyJOB = false;
			break;
			case 1:
			DroneX.Bandits.BanditJob = false;
			DroneX.Bandits.SkippyJOB = false;
			break;
			case 2:
			DroneX.Bandits.BanditJob = false;
			DroneX.Bandits.SkippyJOB = true;
			break;
		}
	};
	
	SkillSpending = function (n) {
		if (DroneX.Saving.SkillSpending != n) {
			DroneX.Saving.SkillSpending = n;
		}
		writeSettings();
		switch (parseInt(n)) {
			case 0:
				DroneX.Saving.SkillToSpend = 'none';
				SkillsTo = 'None';
				break;
			case 1:
				DroneX.Saving.SkillToSpend = 'attack';
				SkillsTo = '<img src="'+DroneX.Imgs.AttackIcon+'"/> Attack!';
				break;
			case 2:
				DroneX.Saving.SkillToSpend = 'defense';
				SkillsTo = '<img src="'+DroneX.Imgs.DefenseIcon+'"/> Defense!';
				break;
			case 3:
				DroneX.Saving.SkillToSpend = 'max_health';
				SkillsTo = '<img src="'+DroneX.Imgs.HealthIcon+'"/> Health!';
				break;
			case 4:
				DroneX.Saving.SkillToSpend = 'max_energy';
				SkillsTo = '<img src="'+DroneX.Imgs.EnergyIcon+'"/> Energy!';
				break;
			case 5:
				DroneX.Saving.SkillToSpend = 'max_stamina';
				SkillsTo = '<img src="'+DroneX.Imgs.StaminaIcon+'"/> Stamina!';
				break;
		}
	};
		
	FightCitySelector = function (n) {
		if (DroneX.Saving.FightCityMenu != n) {
			DroneX.Saving.FightCityMenu = n;
			writeSettings();
		}
		switch (parseInt(n)) {
			case 0:
				DroneX.Saving.FightCity = 1;
				break;
			case 1:
				DroneX.Saving.FightCity = 7;
				break;
			case 2:
				DroneX.Saving.FightCity = 8;
				break;
			case 3:
				DroneX.Saving.FightCity = 9;
				break;
			case 4:
				DroneX.Saving.FightCity = 10;
				break;
			case 5:
				DroneX.Saving.FightCity = 11;
				break;	
		}
	};
	
	IdleCitySelector = function (n) {
		if (DroneX.Saving.IdleCityMenu != n) {
			DroneX.Saving.IdleCityMenu = n;
			writeSettings();
		}
		switch (parseInt(n)) {
			case 0:
				DroneX.Saving.IdleCity = 1;
				break;
			case 1:
				DroneX.Saving.IdleCity = 7;
				break;
			case 2:
				DroneX.Saving.IdleCity = 8;
				break;
			case 3:
				DroneX.Saving.IdleCity = 9;
				break;
			case 4:
				DroneX.Saving.IdleCity = 10;
				break;
			case 5:
				DroneX.Saving.IdleCity = 11;
				break;	
		}
	};
	
	ArenaSelector = function (n) {
		if (DroneX.Saving.ArenaCostMenu != n) {
			DroneX.Saving.ArenaCostMenu = n;
			writeSettings();
		}
			switch (parseInt(n)) {
				case 0:
//					DroneXStaminaMap[DroneX.Saving.PrimaryStaminaInfo].cost = 20;
					DroneX.Saving.arenaSAO = false;
					$('#Arena_Switch_O').hide();
					ArenaReq = 'sw';
					break;
				case 1:
//					DroneXStaminaMap[DroneX.Saving.PrimaryStaminaInfo].cost = 100;
					DroneX.Saving.arenaSAO = false;
					$('#Arena_Switch_O').hide();
					ArenaReq = 'lw';
					break;	
				case 2:
//					DroneXStaminaMap[DroneX.Saving.PrimaryStaminaInfo].cost = 500;
					DroneX.Saving.arenaSAO = true;
					$('#Arena_Switch_O').show();
					ArenaReq = 'hw';
					break;
			}
	};
	
	$('#BGC option:eq('+DroneX.Saving.BG+')').prop('selected', true);
	BGCheck(DroneX.Saving.BG);	
		
	$('#JOBBanO option:eq('+DroneX.Saving.BanditJOBCheck+')').prop('selected', true);
	BanditJOBCheck(DroneX.Saving.BanditJOBCheck);
	
	$('#CSHBanO option:eq('+DroneX.Saving.BanditCSHCheck+')').prop('selected', true);
	BanditCSHCheck(DroneX.Saving.BanditCSHCheck);
	
	$('#XPBanO option:eq('+DroneX.Saving.BanditXPCheck+')').prop('selected', true);
	BanditXPCheck(DroneX.Saving.BanditXPCheck);	
	
	$('#DxSS option:eq(' + DroneX.Saving.SkillSpending + ')').prop('selected', true);
	SkillSpending(DroneX.Saving.SkillSpending);
	
	$('#DXFC option:eq(' + DroneX.Saving.FightCityMenu + ')').prop('selected', true);
	FightCitySelector(DroneX.Saving.FightCityMenu);
	
	$('#WIFT option:eq(' + DroneX.Saving.IdleCityMenu + ')').prop('selected', true);
	IdleCitySelector(DroneX.Saving.IdleCityMenu);
	
	$('#DXAC option:eq(' + DroneX.Saving.ArenaCostMenu + ')').prop('selected', true);
	ArenaSelector(DroneX.Saving.ArenaCostMenu);	
	
	document.getElementById("DXspartacus_seltarget").selectedIndex = DroneX.Saving.arenaSET;
	
	if(parseInt(document.getElementById("user_max_stamina").innerHTML) < 3000){
		document.getElementById("DXAC").options[2].disabled = "disabled";
	}else{
		document.getElementById("DXAC").options[0].disabled = "disabled";
	}
	
	$('#DXspartacus_numatt').bind('keyup',function() {
		if (isNaN(parseInt(this.value)) || parseInt(this.value) > 3 || parseInt(this.value) < 1) {
			this.value = 3;	
		}
		DroneX.Saving.arenaNOA = parseInt(this.value)
		writeSettings();
	});
	
	$('#arena_switch_v').bind('keyup',function() {
		if (isNaN(parseInt(this.value)) || parseInt(this.value) < 1) {
			this.value = 5000;	
		}
		DroneX.Saving.arenaSAV = parseInt(this.value)
		writeSettings();
	});
	
	$('#DXspartacus_boostkami_s').bind('keyup',function() {
		if (isNaN(parseInt(this.value)) || parseInt(this.value) < 1) {
			this.value = 20;	
		}
		DroneX.Saving.arenaBKS = parseInt(this.value)
		writeSettings();
	});
	
	$('#DXspartacus_stoponvalue').bind('keyup',function() {
		if (isNaN(parseInt(this.value)) || parseInt(this.value) < 0) {
			this.value = 0;	
		}
		DroneX.Saving.arenaSOV = parseInt(this.value)
		writeSettings();
	});	
	
	function updateStats(stats_div){
		var stat_count;
		if(stats_div == 'JobDone'){
			stat_count = parseInt($('#JobCounter_'+DroneX.JobMap[DroneX.EnergySelected].isJobID).text());
		}else if(stats_div == 'FobDone'){
			stat_count = parseInt($('#FobCounter_'+DroneX.StamMap[DroneX.StaminaSelected].isJobID).text());
		}else{
			stat_count = parseInt($('#'+stats_div).text());
		}		
		stat_count++
/*		if(DroneX.Saving.MarathonStat){
			DroneX.Saving.LvlupCounter = parseInt($('#LvlUps').text());
			DroneX.Saving.JobCounter = parseInt($('#JobsDone').text());
			writeSettings();
		}*/
		if(stats_div == 'JobDone'){
			$('#JobCounter_'+DroneX.JobMap[DroneX.EnergySelected].isJobID).text(stat_count);
		}else if(stats_div == 'FobDone'){
			$('#FobCounter_'+DroneX.StamMap[DroneX.StaminaSelected].isJobID).text(stat_count);
		}else{
			$('#'+stats_div).text(stat_count);
		}
		if(stats_div != 'LvlUps' && stats_div != 'JobDone' && stats_div != 'FobDone'){
			$('#'+stats_div).text(stat_count);
		}else if(stats_div != 'LvlUps'){
			var totsDone = parseInt($('#TotalJobsDone').text());
			totsDone++;
			$('#TotalJobsDone').text(totsDone);
		}
	}

		function grabInfoz(){ 
			if(!DroneX.isRunning){
				return;
			}
			CloseDoopidPopup();
			GrabCostCount = 0;
			log('Checking Next Action...');
			if(DroneX.JobMapCount < DroneX.JobMap.length){
				if(DroneX.JobMap[DroneX.JobMapCount].isCost == 0){
					log('Grabbing Energy Requirements for '+DroneX.JobMap[DroneX.JobMapCount].isName);
					Dotravel(DroneX.JobMap[DroneX.JobMapCount].isCity, 'job', DroneX.JobMap[DroneX.JobMapCount].isTab, function(){grabENXP(DroneX.JobMapCount);});
					return;
				}else{
					DroneX.JobMapCount++;
					setTimeout(function(){grabInfoz();},1000);
					return;
				}
			}
			if(DroneX.StamMapCount < DroneX.StamMap.length){
				if(DroneX.StamMap[DroneX.StamMapCount].isCost == 0){
					log('Grabbing Stamina Requirements for '+DroneX.StamMap[DroneX.StamMapCount].isName);
					Dotravel(DroneX.StamMap[DroneX.StamMapCount].isCity, 'job', DroneX.StamMap[DroneX.StamMapCount].isTab, function(){grabStamCost(DroneX.StamMapCount);});
					return;
				}else{
					DroneX.StamMapCount++;
					setTimeout(function(){grabInfoz();},1000);
					return;
				}
			}
			if(DroneX.isFirstLoad){
				DroneX.isFirstLoad = false;
				document.getElementById('JobList').innerHTML = '';
				for(var i = 0; i < DroneX.JobMap.length; i++){
					var GetName = parseStuff(DroneX.JobMap[i].isName);
					DroneX.JobMap[i].isName = GetName.name;
					DroneX.JobMap[i].isRatio = GetName.ratio;
					document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:550px; margin:1px;"><img title="Job Mastery" src="'+DroneX.JobMap[i].isMastered+'">'+ DroneX.JobMap[i].isName+' ('+DroneX.JobMap[i].isRatio+') <img title="Job Costs" src="'+DroneX.Imgs.EnergyIcon+'">'+ DroneX.JobMap[i].isCost+' <img title="Job Pays" src="'+DroneX.Imgs.ExpIcon+'">'+DroneX.JobMap[i].isTheXP+' x<span title="Amount of times this job has been attempted" id="JobCounter_'+DroneX.JobMap[i].isJobID+'">0</span></li>';
				}
				for(var i = 0; i < DroneX.StamMap.length; i++){
					if(['Gain The Cooperation Of Key Members Of Parliament (2.163)','Double Cross And Have Them Eliminated (2.222)','Offer Restitution To Terror Attack Victims (2.270)'].indexOf(DroneX.StamMap[i].isName) !== -1){
						var GetName = parseStuff(DroneX.StamMap[i].isName);
						DroneX.StamMap[i].isName = GetName.name;
						DroneX.StamMap[i].isRatio = GetName.ratio;
						document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:550px; margin:1px;"><img src="'+DroneX.StamMap[i].isMastered+'">'+ DroneX.StamMap[i].isName+' ('+DroneX.StamMap[i].isRatio+') <img src="'+DroneX.Imgs.StaminaIcon+'">'+ DroneX.StamMap[i].isCost+' <img src="'+DroneX.Imgs.ExpIcon+'">'+DroneX.StamMap[i].isTheXP+' x<span title="Amount of times this fight job has been attempted" id="FobCounter_'+DroneX.StamMap[i].isJobID+'">0</span></li>';
					}else{
						document.getElementById('JobList').innerHTML += '<li style="list-style: none; background: none repeat scroll 0 0 #111111; border: 1px solid #333333; width:550px; margin:1px;"><img src="'+DroneX.Imgs.FamilyIcon+'">'+ DroneX.StamMap[i].isName+' <img src="'+DroneX.Imgs.StaminaIcon+'">'+ DroneX.StamMap[i].isCost+'</li>';
					}
				}
			}
			DroneX.EnergySelected = CheckEnergyArray();
			DroneX.StaminaSelected = CheckStaminaArray();
			if(DroneX.EnergySelected == 'nonefound'||DroneX.Saving.StamFirst == 1 && DroneX.StaminaSelected != 'nonefound'){
				if(DroneX.StaminaSelected != 'nonefound'){
					DroneX.switchNRG = parseInt(document.getElementById('user_energy').innerHTML);
					document.getElementById('ActiveJob').innerHTML = '<img src="'+DroneX.StamMap[DroneX.StaminaSelected].isMastered+'">' +DroneX.StamMap[DroneX.StaminaSelected].isName;
					if(DroneX.StamMap[DroneX.StaminaSelected].isName == "Killer Kami"){
						logit('to kami?')
						goRedFightTab();
						return
					}else if(!DroneX.StamMap[DroneX.StaminaSelected].isRobbing && !DroneX.StamMap[DroneX.StaminaSelected].isArena){
						logit('to fob?')
						document.getElementById('ActiveJob').innerHTML += ' ('+DroneX.StamMap[DroneX.StaminaSelected].isRatio+')';
						var JobToClick = $('#btn_dojob_'+DroneX.StamMap[DroneX.StaminaSelected].isJobID).get(0);
						if (JobToClick){
							if(DroneX.StamMap[DroneX.StaminaSelected].isCity == MyLocation()){
								log('Quick switch, no traveling required!')
								setTimeout(function(){PreFobChecker();},1000);
								return;
							}
						}
						Dotravel(DroneX.StamMap[DroneX.StaminaSelected].isCity, 'job', DroneX.StamMap[DroneX.StaminaSelected].isTab, function(){PreFobChecker();});
						return;
					}else if(DroneX.StamMap[DroneX.StaminaSelected].isRobbing){
						logit('to rob?')
						Dotravel(DroneX.StamMap[DroneX.StaminaSelected].isCity, 'robbing', DroneX.StamMap[DroneX.StaminaSelected].isTab, function(){PreRob();});
						return;
					}else{
						logit('to spart?')
						$('#gxRDivS').show();
						startarena();
						return;
					}
				}
			}
			if(DroneX.EnergySelected == 'nonefound' && DroneX.StaminaSelected == 'nonefound'){
				setTimeout(function(){check_resources(grabInfoz);},1000);
				return;		
			}
			document.getElementById('ActiveJob').innerHTML = '<img src="'+DroneX.JobMap[DroneX.EnergySelected].isMastered+'">' +DroneX.JobMap[DroneX.EnergySelected].isName+' ('+DroneX.JobMap[DroneX.EnergySelected].isRatio+')';
			if(DroneX.JobMap[DroneX.EnergySelected].isRationOn){
				document.getElementById('ActiveJob').innerHTML += ' switching to next job when global ratio is below: '+DroneX.JobMap[DroneX.EnergySelected].RatioVal;
			}else if(DroneX.JobMap[DroneX.EnergySelected].isNRGSwitchOn){
				document.getElementById('ActiveJob').innerHTML += ' switching to next job when Energy is below: '+DroneX.JobMap[DroneX.EnergySelected].isNRGValue;
			}
			var JobToClick;
			if(DroneX.JobMap[DroneX.EnergySelected].isUsingButton) {
				JobToClick = $('#btn_dojob_'+DroneX.JobMap[DroneX.EnergySelected].isJobID).get(0);
			}else if(DroneX.JobMap[DroneX.EnergySelected].isOldCity){
				JobToClick = $('#city_job_'+ DroneX.JobMap[DroneX.EnergySelected].isJobID +' > .job_action > a').get(0);
			}else{
				JobToClick = $('#job_'+ DroneX.JobMap[DroneX.EnergySelected].isJobID +' > a').get(0);
			}
			if(JobToClick){
				if(DroneX.JobMap[DroneX.EnergySelected].isCity == MyLocation()){
					log('Quick switch, no traveling required!')
					setTimeout(function(){PreJobChecker();},1000);
					return;
				}
			}
			Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});
		}

		function parseStuff(str) { // By Esa
			var re = /^(.*?)\(([0-9.]+)\)/
			var matches = str.match( re );
			if( matches && matches.length == 3 ) {
				return {
					name: matches[1],
					ratio: parseFloat(matches[2]).toFixed(3)
				}
			}
			return null;
		}	
			
		function grabENXP(num){
			if(!DroneX.isRunning){
				return;
			}
			var JobToCheck;
			if(DroneX.JobMap[num].isUsingButton) {
				JobToCheck = $('#btn_dojob_' + DroneX.JobMap[num].isJobID);
			}else {
				JobToCheck = $('#city_job_'+ DroneX.JobMap[num].isJobID);
			}
			if (JobToCheck.length < 1){
				GrabCostCount++;
				if(GrabCostCount > 3){
					GrabCostCount = 0;
					Dotravel(DroneX.JobMap[DroneX.JobMapCount].isCity, 'job', DroneX.JobMap[DroneX.JobMapCount].isTab, function(){grabENXP(num);});
					return;
				}
				setTimeout(function(){grabENXP(num);},5000);
				return;
			}
			if(DroneX.JobMap[num].isOldCity){
				DroneX.JobMap[num].isCost = parseInt($('#city_job_' + DroneX.JobMap[num].isJobID + ' > .job_energy > .energy').text());
				DroneX.JobMap[num].isTheXP = parseInt($('#city_job_' + DroneX.JobMap[num].isJobID + ' > .job_reward > .experience').text());
				DroneX.JobMap[num].isRatio = (DroneX.JobMap[num].isTheXP/DroneX.JobMap[num].isCost).toFixed(3);
				try{
					var getmastery = $('#city_job_' + DroneX.JobMap[num].isJobID + ' > .job_name').text();
					if (getmastery == null||getmastery.length < 1){
						setTimeout(function(){grabENXP(num);},5000);
						return;
					}
					if(/Level 3 Mastered/.test(getmastery)){
					//Gold mastery
						DroneX.JobMap[num].isMastered = DroneX.Imgs.GoldStar;
					}else if(/Level 2 Mastered/.test(getmastery)){
					//Silver mastery
						DroneX.JobMap[num].isMastered = DroneX.Imgs.SilverStar;
					}else{
					//Bronze mastery
						DroneX.JobMap[num].isMastered = DroneX.Imgs.BronzeStar;
					}
				}catch(none){
					DroneX.JobMap[num].isMastered = DroneX.Imgs.RubyStar;
				}
			}else {
/*				if(DroneX.JobMap[num].isCity == 11) {
					try {
						var isBoss = $('#boss-district-job-top-hud > .boss-img > img').attr('src');
						if(isBoss.indexOf('active') > -1){
							DroneX.JobMap[num].isCost = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID + ' > .job_details.clearfix > .boss_active > .uses.clearfix > .energy').attr('current_value'));
							DroneX.JobMap[num].isTheXP = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID + ' > .job_details.clearfix > .boss_active > .pays.clearfix > .experience').attr('current_value'));
						}else{
							DroneX.JobMap[num].isCost = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID + ' > .job_details.clearfix > .uses.clearfix > .energy').attr('current_value'));
							DroneX.JobMap[num].isTheXP = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID + ' > .job_details.clearfix > .pays.clearfix > .experience').attr('current_value'));
							
						}
					}catch(mexboss){}
				}else{
					DroneX.JobMap[num].isCost = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID + ' > .job_details.clearfix > .uses.clearfix > .energy').attr('current_value'));
					DroneX.JobMap[num].isTheXP = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID + ' > .job_details.clearfix > .pays.clearfix > .experience').attr('current_value'));
				}*/
//				logit(DroneX.JobMap[num].isCost)
//				logit(DroneX.JobMap[num].isTheXP)
				DroneX.JobMap[num].isCost = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID).find('li.energy:last').attr('current_value'));
				DroneX.JobMap[num].isTheXP = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID).find('li.experience:last').attr('current_value'));
				DroneX.JobMap[num].isRatio = (DroneX.JobMap[num].isTheXP/DroneX.JobMap[num].isCost).toFixed(3);
				try{
					var MasteredSoFar = $('#job-id-' + DroneX.JobMap[num].isJobID).closest("[class^='district']").attr('class'); //district  mastery_level_2
					if (MasteredSoFar == null||MasteredSoFar.length < 1){
						setTimeout(function(){grabENXP(num);},5000);
						return;
					}
					var MasteredSoFarSplit = MasteredSoFar.split('_');
					if(parseInt(MasteredSoFarSplit[2]) == 4){
					//ruby mastery
						DroneX.JobMap[num].isMastered = DroneX.Imgs.RubyStar;
					}else if(parseInt(MasteredSoFarSplit[2]) == 3){
					//Gold mastery
						DroneX.JobMap[num].isMastered = DroneX.Imgs.GoldStar;
					}else if(parseInt(MasteredSoFarSplit[2]) == 2){
					//Silver mastery
						DroneX.JobMap[num].isMastered = DroneX.Imgs.SilverStar;
					}else if(parseInt(MasteredSoFarSplit[2]) == 1||MasteredSoFarSplit[2] == null){
					//Bronze mastery
						DroneX.JobMap[num].isMastered = DroneX.Imgs.BronzeStar;
					}
				}catch(none){
					DroneX.JobMap[num].isMastered = DroneX.Imgs.RubyStar;
				}
			}
			if(DroneX.JobMap[num].isCost == 0||isNaN(DroneX.JobMap[num].isCost)){
				logit('errr'+DroneX.JobMap[num].isCost)
				Dotravel(DroneX.JobMap[num].isCity, 'job', DroneX.JobMap[num].isTab, function(){grabENXP(num);});
			}else{
				setTimeout(function(){grabInfoz();},5000);
			}
		}
		
		function grabStamCost(num){
			if(!DroneX.isRunning){
				return;
			}
			var JobToCheck = $('#btn_dojob_'+DroneX.StamMap[num].isJobID)
			if (JobToCheck.length < 1){
				GrabCostCount++;
				if(GrabCostCount > 3){
					GrabCostCount = 0;
					Dotravel(DroneX.StamMap[DroneX.StamMapCount].isCity, 'job', DroneX.StamMap[DroneX.StamMapCount].isTab, function(){grabStamCost(num);});
					return;
				}
				setTimeout(function(){grabStamCost(num);},5000);
				return;
			}
			DroneX.StamMap[num].isCost = parseInt($('#job-id-' + DroneX.StamMap[num].isJobID + ' > .job_details.clearfix > .uses.clearfix > .stamina').attr('current_value'));
			DroneX.StamMap[num].isTheXP = parseInt($('#job-id-' + DroneX.StamMap[num].isJobID + ' > .job_details.clearfix > .pays.clearfix > .experience').attr('current_value'));
			DroneX.StamMap[num].isRatio = (DroneX.StamMap[num].isTheXP/DroneX.StamMap[num].isCost).toFixed(3);
			try{
				var MasteredSoFar = $('#job-id-' + DroneX.StamMap[num].isJobID).closest("[class^='district']").attr('class'); //district  mastery_level_2
				if (MasteredSoFar == null||MasteredSoFar.length < 1){
					setTimeout(function(){grabStamCost(num);},5000);
					return;
				}
				var MasteredSoFarSplit = MasteredSoFar.split('_');
				if(parseInt(MasteredSoFarSplit[2]) == 4){
				//ruby mastery
					DroneX.StamMap[num].isMastered = DroneX.Imgs.RubyStar;
				}else if(parseInt(MasteredSoFarSplit[2]) == 3){
				//Gold mastery
					DroneX.StamMap[num].isMastered = DroneX.Imgs.GoldStar;
				}else if(parseInt(MasteredSoFarSplit[2]) == 2){
				//Silver mastery
					DroneX.StamMap[num].isMastered = DroneX.Imgs.SilverStar;
				}else if(parseInt(MasteredSoFarSplit[2]) == 1||MasteredSoFarSplit[2] == null){
				//Bronze mastery
					DroneX.StamMap[num].isMastered = DroneX.Imgs.BronzeStar;
				}
			}catch(none){
				DroneX.StamMap[num].isMastered = DroneX.Imgs.RubyStar;
			}
			if(DroneX.StamMap[num].isCost == 0||isNaN(DroneX.StamMap[num].isCost)){
				Dotravel(DroneX.StamMap[DroneX.StamMapCount].isCity, 'job', DroneX.StamMap[DroneX.StamMapCount].isTab, function(){grabStamCost(num);});
			}else{
				setTimeout(function(){grabInfoz();},5000);
			}
		}
		
		function CheckEnergyArray() {
			if(!DroneX.isRunning){
				return;
			}
			var isListReset = false;
			if(DroneX.Saving.RemoveJobs){
				//Check for disabled Jobs
				for (var i =0; i < DroneX.JobMap.length; i++){
					if (DroneX.JobMap[i].isEnabled === false) {
						//remove a job from the array
						DroneX.JobMap.splice(i,1);
						//decrease the count since b is now a
						i--
						//reset the job list
						DroneX.isFirstLoad = true;
						//trigger the list to get rebuilt
						isListReset = true;
					}
				}
				//end removing
			}
			if(DroneX.JobMap.length < 1){
				log('All Jobs were removed, Either out of cash or consumables...');
				$('#stop').click();
				return;
			}
			DroneX.JobMap[DroneX.JobMap.length-1].isRationOn = false;
			DroneX.JobMap[DroneX.JobMap.length-1].isNRGSwitchOn = false;		
			if(isListReset){
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			var Energy = parseInt(document.getElementById('user_energy').innerHTML);
			var fail = 'nonefound';
			var CurrentNRG = parseInt(document.getElementById('user_energy').innerHTML);
			var CurrentSTAM = parseInt(document.getElementById('user_stamina').innerHTML);
			var CurrentXP2LVL = parseInt(document.getElementById('exp_to_next_level').innerHTML);
			var combinedEn2xp = (CurrentXP2LVL/(CurrentNRG+CurrentSTAM)).toFixed(2);
	/*		for(var i=0; i< DroneX.JobMap.length; i++) {
				if (DroneX.JobMap[i].isCost <= Energy) {
					return i;
				}else if(i == DroneX.JobMap.length-1){
					return fail;
				}
			}
			for(var i=0; i< DroneX.JobMap.length; i++) {
				if (DroneX.JobMap[i].isCost <= Energy) {
					return i;
				}else if(i == DroneX.JobMap.length-1){
					return fail;
				}
			} */
			for(var i = 0; i < DroneX.JobMap.length; i++) {
				if(DroneX.JobMap[i].isRationOn && DroneX.JobMap[i].RatioVal >= combinedEn2xp && DroneX.JobMap[i+1].isCost <= Energy||DroneX.JobMap[i].isNRGSwitchOn && DroneX.JobMap[i].isNRGValue >= Energy && DroneX.JobMap[i+1].isCost <= Energy){
					if(DroneX.JobMap[i+1].isSkipping && DroneX.JobMap[DroneX.JobMap.length-1] != DroneX.JobMap[i+1] && DroneX.JobMap[i+2].isCost <= Energy){
						DroneX.JobMap[i+1].isSkipping = false;
						return i+2;
					}else{
						return i+1;
					}
				}else if(DroneX.JobMap[i].isNRGSwitchOn && DroneX.JobMap[i].isNRGValue >= Energy){
					try{
						if(DroneX.JobMap[i+2].isCost <= Energy){
							if(DroneX.JobMap[i+2].isSkipping && DroneX.JobMap[DroneX.JobMap.length-1] != DroneX.JobMap[i] && DroneX.JobMap[i+3].isCost <= Energy){
								DroneX.JobMap[i+2].isSkipping = false;
								return i+3;
							}else{
								return i+2;
							}							
						}else if(DroneX.JobMap[i+3].isCost <= Energy){
							if(DroneX.JobMap[i+3].isSkipping && DroneX.JobMap[DroneX.JobMap.length-1] != DroneX.JobMap[i] && DroneX.JobMap[i+4].isCost <= Energy){
								DroneX.JobMap[i+3].isSkipping = false;
								return i+4;
							}else{
								return i+3;
							}							
						}
					}catch(patrick){}
				}else if (DroneX.JobMap[i].isCost <= Energy) {
					if(DroneX.JobMap[i].isSkipping && DroneX.JobMap[DroneX.JobMap.length-1] != DroneX.JobMap[i] && DroneX.JobMap[i+1].isCost <= Energy){
						DroneX.JobMap[i].isSkipping = false;
						return i+1;
					}else{
						return i;
					}
				}else if(i == DroneX.JobMap.length-1){
					return fail;
				}
			}	
		}		

		function CheckStaminaArray() {
			var isListReset = false;
			if(DroneX.Saving.RemoveJobs){
				//Check for disabled Jobs
				for (var i =0; i < DroneX.StamMap.length; i++){
					if (DroneX.StamMap[i].isEnabled === false) {
						if(DroneX.StamMap[i].isCost == 25){
							DroneX.StamMap[i].isEnabled = true; // whoops robbing got disabled, add that back in
						}else{
							//remove a job from the array
							DroneX.StamMap.splice(i,1);
							//decrease the count since b is now a
							i--
							//reset the job list
							DroneX.isFirstLoad = true;
							//trigger the list to get rebuilt
							isListReset = true;
						}
					}
				}
				//end removing check
			}
			if(DroneX.StamMap.length < 1){
				log('All Stamina Jobs were removed, Either out of cash or consumables...');
				$('#stop').click();
				return;
			}
			if(isListReset){
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			var Stamina = parseInt(document.getElementById('user_stamina').innerHTML);
			var fail = 'nonefound';
			for(var i=0; i< DroneX.StamMap.length; i++) {
				if (DroneX.StamMap[i].isCost <= Stamina) {
					return i;
				}else if(i == DroneX.StamMap.length-1){
					return fail;
				}
			}
		}
		
		function check_resources(handler, famxpdown) {
			log('Checking resources...');
			AjxRequest('xw_controller=propertyV2&xw_action=createData&xw_city=10&tmp=&cb=&xw_person='+User.id.substr(2)+'&mwcom=1&city=10&xw_client_id=8', function(msg){
				try {
					var data = JSON.parse(msg);
					document.getElementById('user_energy').innerHTML = data.user_fields.user_energy;
					document.getElementById('user_stamina').innerHTML = data.user_fields.user_stamina;
					var stamavail=data.user_fields.user_stamina;
					var xpneed=data.user_fields.exp_to_next_level;
				} catch(e) {
					logit('Error parsing JSON, retry in 5s...');
					setTimeout(check_resources,5000,handler);
					return;
				}
				var DoesIHaveEnergy = parseInt(document.getElementById('user_energy').innerHTML);
				var DoesIHaveStamina = parseInt(document.getElementById('user_stamina').innerHTML);
				log('You have <img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon-energy.gif"> '+DoesIHaveEnergy+' <img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon_stamina_16x16.png"> '+DoesIHaveStamina);
				var can_restart = true;
				if(DoesIHaveEnergy > DroneX.JobMap[DroneX.JobMap.length-1].isCost||DoesIHaveStamina > DroneX.StamMap[DroneX.StamMap.length-1].isCost){
					can_restart = true;
				} else {
					can_restart = false;
				}
				if (can_restart) {
					handler();
				} else {
					SPAvaiable = parseInt($('#user_skill').text());	
					if(SPAvaiable > 0 && DroneX.Saving.SkillToSpend != 'none'){
						SkillPointAssinRunning = true;
						SpendSkillCycle();
						return;
					}
					if($('#Dx_famXP').is(':checked')&& famxpdown != 'true'){
//						Dotravel(10, 'job', 1, function(){familyXPCollector();});
						Dotravel(10, 'homeit', 'homeit', function(){familyXPCollector();});
						return;
					}
					if($('#Dx_restart').is(':checked')){
						if(MyLocation() != DroneX.Saving.IdleCity){
							Dotravel(DroneX.Saving.IdleCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab);
						}
						$('#nav_link_home_unlock > a').click();
						var wait = parseInt($('#Dx_Restarttime').val()*60*1000);
						log('Outta NRG & Stamina restarting in '+DroneX.Saving.RestartIn+' minutes ('+displayTime(DroneX.Saving.RestartIn)+')');
						$('#Activity').append(' <a href="#" id="insta_RS">(Restart Now)</a>');
						ClickGo = setTimeout(function(){grabInfoz();},wait)
						$('#insta_RS').click(function(){
							clearTimeout(ClickGo);
							log('Attempting a restart...');
							setTimeout(function(){grabInfoz();},1000);				
							return false;
						});
					}else{
						log('Outta NRG & Stamina');
						$('#stop').click();
					}
				}
			});
		}
		
		function Dotravel(destination, from, tab, callback) {
			if(!DroneX.isRunning){
				return;
			}
			CloseDoopidPopup();
			var userid = /sf_xw_user_id': '(.+)'/.exec(document.body.innerHTML)[1];
			var fromCity = CurrentCity();
			var url = 'html_server.php?xw_controller=travel&xw_action=travel';
			var data = {
				'ajax': 1,
				'liteload': 1,
				'sf_xw_user_id': userid,
				'sf_xw_sig': local_xw_sig,  
				'cb': (userid + parseInt(new Date().getTime().toString().substring(0, 10))),
				'xw_client_id': 8,
				'destination': destination || 1,
				'from': from || 'job',
				'tab': tab || 1,
				'zone': 1
			};
			if(tab == 'robbing'){
				delete data.tab;	
			}
			if(tab == 'homeit'){
				do_ajax('inner_page', 'remote/html_server.php?xw_controller=index&xw_action=view', 1, 1, 0, 0); 
				if (typeof callback == 'function'){
					log('Finishing pageload..');
					setTimeout(function(){
						callback && callback();
					},5000);
				}
				return;
/*				url = 'html_server.php?xw_controller=index&xw_action=view&xw_city=1&xw_person=146386698&mwcom=1';
				delete data.ajax;	
//				delete data.liteload;	
				data.alignTop = 1;
				delete data.sf_xw_user_id;	
				delete data.sf_xw_sig;	
				delete data.cb;	
				delete data.destination;	
				delete data.from;
				delete data.tab;
				delete data.zone;		*/
			}
			if(tab == 'arena'){
				if (typeof callback == 'function'){
					log('Finishing pageload..');
					setTimeout(function(){
						callback && callback();
					},1000);
				}
				return;
			}
			$.ajax({
				url:url,
				data:data,
				success: function (htmlText) {
					var $htmlText = $(htmlText);
					$('#inner_page').empty();
					$('#inner_page').html(htmlText);
					User.page = setCurrentCity(htmlText);
					if (fromCity != (CurrentCity($htmlText))) {
						if (typeof callback == 'function'){
							log('Finishing pageload..');
							setTimeout(function(){
								callback && callback();
							},DroneX.Saving.PageLoadSpeed);
						}
					}
				},
				error: function (EEEE){
					setTimeout(function(){ Dotravel(destination, from, tab, function(){
							callback();
						}); 
					},5000);
				}
			});

			function CurrentCity(html) {
				var CityData = html || document.body.innerHTML;
				var CurrentCityr;
				if (/current_city_id'.\s*=\s*parseInt."(\d)".;/i.test(CityData)) {
					CurrentCityr = /current_city_id'.\s*=\s*parseInt."(\d)".;/i.exec(CityData)[1];
				} else {
					CurrentCityr = String($(CityData).find('#mw_city_wrapper').attr('class')).substring(7);
				}
				return (CurrentCityr)
			}
		}
		
		function setCurrentCity(shtml) {
			// get User object, error free, undefined if not found.
			var usr = User&&User.page ? User : (unsafeWindow||window||{}).User;
			if (!(usr && usr.page)){
				// in case no User object, some weird thing happens, abort.
				logit('Fatal error: No user object found.');
			} else {
				// only if response is a valid string
				if (typeof shtml === 'string') {
					// match only in full page loads.
					var page_rex = /Page:\s*([a-zA-Z]*)_controller/i;
					// test if the page is a full page load
					if (page_rex .test(shtml)) {
						// assign page name to User.page game var.
						usr.page = page_rex.exec(shtml)[1];
						// assign page name to game inner div.
						$('#inner_page').attr('class', usr.page + '_controller');
					}
				}
			// end else
			}
			// return current page, if assign fails, return the old one.
			return usr.page;
		}
		
		function AjxRequest(url, handler, errorhandler) {
			var zserver = /\/\/(.*)\.mafiawars/.exec(document.location.href)[1];
			if(url.indexOf('html_server.php') >= 0){
				url = url.substr(url.indexOf('?')+1);
			}
			User.clicks++;
			var params = {
				'ajax': 1,
				'liteload': 1,
				'sf_xw_user_id': User.id,
				'sf_xw_sig': local_xw_sig,
				'xw_client_id': 8,
				'skip_req_frame': 1,
				'clicks': User.clicks
			};
			var preurl = '//'+zserver+'.mafiawars.zynga.com/mwfb/remote/html_server.php?';
			function processRequest() {
				$.ajax({
					type: "POST",
					url: preurl+url,
					data: params,
					cache: false,
					success: function (e) {
						handler(e)
					},
					timeout: 30000,
					error: function () {
						setTimeout(function(){processRequest();},5000);
					}
				});
			}
			processRequest()
		}
		
		function MyLocation(){
			var here = /mw_city(\d+)/.exec(document.getElementById('mw_city_wrapper').className)[1]; 
			return here;
		}
		
		function PreJobChecker(){
			if(!DroneX.isRunning){
				return;
			}
			CloseDoopidPopup();
			log('Pre Checking Job Environment...')
			if (/These loot drops are needed for this job/.test(document.body.innerHTML)) {
				log('Not enough consumables..');
				DroneX.JobMap[DroneX.EnergySelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			if (/You do not have enough cash to do this job/.test(document.body.innerHTML)) {
				log('Not enough cash..');
				DroneX.JobMap[DroneX.EnergySelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;		
			}
			if (/There are no secret districts currently open!/.test(document.body.innerHTML)) {
				log('Secret District Appears to of gone walkies..');
				DroneX.JobMap[DroneX.EnergySelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;		
			}
			if (/- Locked/.test(document.body.innerHTML)) {
				log('Secret District Not unlocked!');
				DroneX.JobMap[DroneX.EnergySelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;		
			}
			if (/MW: This link has expired. Please reload./.test(document.body.innerHTML)) {
				log('Refreshing Session!');
				DroneX.JobMap[DroneX.EnergySelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			if (/Your session has timed out. Click any button to resume playing./.test(document.body.innerHTML)) {
				log('Refreshing Session!');
				DroneX.JobMap[DroneX.EnergySelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;
			}		
			var onMarketPlace = document.evaluate('//div[contains(@class, "marketplace_controller")]//a[contains(., "ALL ITEMS")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength > 0;
			if(onMarketPlace > 0){
				log('Marketplace Tab, Why i go here..');
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			var DoesIHaveEnergy = parseInt(document.getElementById('user_energy').innerHTML);
			var DoesIHaveStam = parseInt(document.getElementById('user_stamina').innerHTML);
			var CurrentSTAM = parseInt(document.getElementById('user_stamina').innerHTML);
			var CurrentXP2LVL = parseInt(document.getElementById('exp_to_next_level').innerHTML);
			combinedEn2xp = (CurrentXP2LVL/(DoesIHaveEnergy+CurrentSTAM)).toFixed(2);
			if(DroneX.Saving.StamFirst == 1 && DoesIHaveStam >= DroneX.StamMap[0].isCost){
				if(isBandit() && Bandit_type == "XP Bandit"){
					$('#job-id-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).find('.bandit-eliminate-btn > a').click();
				}
				setTimeout(function(){grabInfoz();},3000);
				return;
			}
			try {
				if(DroneX.JobMap[DroneX.EnergySelected].isCity == 11) {
					var d;
					d = '';
					var mynuma = DroneX.JobMap[DroneX.EnergySelected].isCost; 
					var myxpnum = DroneX.JobMap[DroneX.EnergySelected].isTheXP;
				/*	var isBoss;
					try{
						isBoss = $('#boss-district-job-top-hud > .boss-img > img').attr('src');
					}catch(mexboss){}*/
					var energycostme; 
					var xppayme;
					/*if(isBoss.indexOf('active') > -1){
						energycostme = parseInt($('#job-id-' + DroneX.JobMap[DroneX.EnergySelected].isJobID + ' > .job_details.clearfix > .boss_active > .uses.clearfix > .energy').attr('current_value'));
						xppayme = parseInt($('#job-id-' + DroneX.JobMap[DroneX.EnergySelected].isJobID + ' > .job_details.clearfix > .boss_active > .pays.clearfix > .experience').attr('current_value'));
					}else{
						energycostme = parseInt($('#job-id-' + DroneX.JobMap[DroneX.EnergySelected].isJobID + ' > .job_details.clearfix > .uses.clearfix > .energy').attr('current_value'));
						xppayme = parseInt($('#job-id-' + DroneX.JobMap[DroneX.EnergySelected].isJobID + ' > .job_details.clearfix > .pays.clearfix > .experience').attr('current_value'));
					}*/
					energycostme = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID).find('li.energy:last').attr('current_value'));
					xppayme = parseInt($('#job-id-' + DroneX.JobMap[num].isJobID).find('li.experience:last').attr('current_value'));
					if(energycostme == null){
						logit('ererer');
						setTimeout(PreJobChecker, 500);
						return;
					}
					if (mynuma != energycostme) {
						DroneX.JobMap[DroneX.EnergySelected].isCost = energycostme;
						DroneX.JobMap[DroneX.EnergySelected].isTheXP = xppayme;
						d = 'Learnt new energy cost, energy cost per job is now ' + energycostme + ' & XP Payout is ' + xppayme + '';
						log(d);
					}
				}
			} catch (err) {}
			if(DoesIHaveEnergy < DroneX.JobMap[DroneX.EnergySelected].isCost){
				if(isBandit() && Bandit_type == "XP Bandit"){
					$('#job-id-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).find('.bandit-eliminate-btn > a').click();
					setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},3000);
					return;				
				}
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			var Switchback = doSwitch();
			if(Switchback == 'Switch'){
				if(isBandit() && Bandit_type == "XP Bandit"){
					$('#job-id-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).find('.bandit-eliminate-btn > a').click();
					setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},3000);
					return;
				}
				log('Switching to next job...');
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			if(DroneX.JobMap[DroneX.EnergySelected].isRationOn && DroneX.JobMap[DroneX.EnergySelected].RatioVal >= combinedEn2xp && DoesIHaveEnergy >= DroneX.JobMap[DroneX.EnergySelected+1].isCost||DroneX.JobMap[DroneX.EnergySelected].isNRGSwitchOn && DroneX.JobMap[DroneX.EnergySelected].isNRGValue >= DoesIHaveEnergy && DoesIHaveEnergy >= DroneX.JobMap[DroneX.EnergySelected+1].isCost){
				if(isBandit() && Bandit_type == "XP Bandit"){
					$('#job-id-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).find('.bandit-eliminate-btn > a').click();
					setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},3000);
					return;
				}
				log('Switching to next job...');
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
	/*		if(DroneX.JobMap[0].isRationOn && DroneX.JobMap[DroneX.EnergySelected].isJobID != DroneX.JobMap[0].isJobID && combinedEn2xp > DroneX.JobMap[0].RatioVal && DroneX.JobMap[0].isCost < DoesIHaveEnergy||DroneX.JobMap[0].isNRGSwitchOn && DroneX.JobMap[0].isNRGValue < DoesIHaveEnergy && DroneX.EnergySelected != 0){
				if(isBandit() && Bandit_type == "XP Bandit"){
					$('#job-id-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).find('.bandit-eliminate-btn > a').click();
					setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},3000);
					return;			
				}
				log('Switching jobs...');
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			if(DroneX.JobMap[DroneX.EnergySelected].isJobID != DroneX.JobMap[0].isJobID && !DroneX.JobMap[0].isRationOn && !DroneX.JobMap[0].isNRGSwitchOn){
				if(DroneX.JobMap[0].isCost < DoesIHaveEnergy){
					if(isBandit() && Bandit_type == "XP Bandit"){
						$('#job-id-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).find('.bandit-eliminate-btn > a').click();
						setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},3000);
						return;			
					}
					log('changing jobs...');
					setTimeout(function(){grabInfoz();},1000);
					return;
				}
			}*/
			var JobToClick;
			if(DroneX.JobMap[DroneX.EnergySelected].isUsingButton) {
				JobToClick = $('#btn_dojob_'+DroneX.JobMap[DroneX.EnergySelected].isJobID).prop('href');
			}else if(DroneX.JobMap[DroneX.EnergySelected].isOldCity){
				JobToClick = $('#city_job_'+ DroneX.JobMap[DroneX.EnergySelected].isJobID +' > .job_action > a').attr('href');
			}else{
				JobToClick = $('#job_'+ DroneX.JobMap[DroneX.EnergySelected].isJobID +' > a').attr('href');
			}
			if (JobToClick == null||JobToClick.length < 1){
				log('job el is null, Reloading Page')
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			if(DroneX.JobMap[DroneX.EnergySelected].isCity != /mw_city(\d+)/.exec(document.getElementById('mw_city_wrapper').className)[1]){
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			try{	
				var hazbeenposted = $('#btn_crew_recruit').text();
				var tellmeNow = /Ask/g;
				var Annnnd = tellmeNow.test(hazbeenposted);
				if(Annnnd && parseInt(document.getElementById('btn_queue').childNodes[0].childNodes[0].childNodes[2].innerHTML) <= DroneX.Saving.CrewAmount && DroneX.Saving.AutopostingCrew){
					if(crewposted == 0){
						crewposted = 1;
						AjxRequest('html_server.php?xw_controller=job&xw_action=view&xw_city='+MyLocation()+'&xw_person='+ User.id, function (jsonData) {
							var doRecruitButtonFeed = substr(jsonData, 'doRecruitButtonFeed: function() {', 'MW.Feed(feed)');
							if(doRecruitButtonFeed && /accept_city_crew_feed/.test(doRecruitButtonFeed)) {
								doRecruitButtonFeed = doRecruitButtonFeed + ' end_of_crew'
								var feed = substr(doRecruitButtonFeed, 'var feed = {', 'end_of_crew');
								eval(feed);
								feed.autoPublish = true;
								window.MW.Feed(feed)
								log('<span class="good">Crew was under 18, so have posted for some..</span>');
							}else{
								log('<span class="bad">Issues Posting for crew!</span>')
							}
						});
						setTimeout(function () {
							crewpostr();
						}, 1000*60*60); 
					}
				}
			}catch(err){}
			if (isBandit()) {
				var crewMembers = parseInt(document.getElementById('btn_queue').childNodes[0].childNodes[0].childNodes[2].innerHTML);
				if ($('#job-id-' + DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-' + DroneX.JobMap[DroneX.EnergySelected].isJobID).find('.bandit-eliminate-btn > a').length == 0) {
					log('<span class="bad">MW Not displaying Bandit properly!</span>');
					Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});
					return;
				}
				var Bandit_Elim = $('#job-id-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-'+DroneX.JobMap[DroneX.EnergySelected].isJobID).find('.bandit-eliminate-btn > a');
				var sillyBTimer = $('#job-id-' + DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-' + DroneX.JobMap[DroneX.EnergySelected].isJobID).children().children('.bandit-wrapper').children('.bandit-wrapper-inner').children('.bandit-timer').text();
				var texBandit = parseInt(sillyBTimer);
				if(isNaN(texBandit)){
					sillyBTimer = 'Not detected';
					texBandit = parseInt(BUBT);
				}else{
					BUBT = sillyBTimer;
				}
				if (crewMembers == 0) {
					log('<span class="bad">Not Killing '+Bandit_type+'... Because no Crew!</span>');
					BUBT = 6;
					BanditSkipperTimer = setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},5*60*1000);
					$('#Activity').append(' <a href="#" id="SkipBanditJob">(Skip to Next Job?)</a>');
					$('#SkipBanditJob').click(function(){
						clearTimeout(BanditSkipperTimer);
						DroneX.JobMap[DroneX.EnergySelected].isSkipping = true;
						log('Attempting to Skip Job...');
						setTimeout(function(){grabInfoz();},1000);				
						return false;
					});
					if(DroneX.Saving.Skippy){
						$('#SkipBanditJob').click();
					}
					return;
				}
				if(Bandit_type == "Job Bandit"){
					if(DroneX.Bandits.BanditJob){
						log('<span class="bad">Attempting to Kill '+Bandit_type+'...</span>');
						Bandit_Elim.click();
						BUBT = 6;
						setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},3000);
						return;
					}else{
						log('<span class="bad">Not Killing '+Bandit_type+'...</span>');
						BUBT = 6;
						BanditSkipperTimer = setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},5*60*1000);
						$('#Activity').append(' <a href="#" id="SkipBanditJob">(Skip to Next Job?)</a>');
						$('#SkipBanditJob').click(function(){
							clearTimeout(BanditSkipperTimer);
							DroneX.JobMap[DroneX.EnergySelected].isSkipping = true;
							log('Attempting to Skip Job...');
							setTimeout(function(){grabInfoz();},1000);				
							return false;
						});
						if(DroneX.Bandits.SkippyJOB){
							$('#SkipBanditJob').click();
						}
						return;
					}
				}else if(Bandit_type == "Cash Bandit"){
					if(DroneX.Bandits.lolzatcash){
						setTimeout(function(){ClickJob();},100);
						return;
					}
					if(!DroneX.Bandits.BanditGamblerCSH || texBandit <= DroneX.Bandits.BanditElapsedTimerCash){
						log('<span class="bad">Attempting to Kill '+Bandit_type+'...</span>');
						Bandit_Elim.click();
						BUBT = 6;
						setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},3000);
						return;
					}
				}else if(Bandit_type == "XP Bandit"){
					if(DroneX.Bandits.SkippyXP){
						DroneX.JobMap[DroneX.EnergySelected].isSkipping = true;
						log('Attempting to Skip Job...');
						setTimeout(function(){grabInfoz();},1000);
						return;
					}
					if(!DroneX.Bandits.BanditGamblerXP || texBandit <= DroneX.Bandits.BanditElapsedTimerXP){
						log('<span class="bad">Attempting to Kill '+Bandit_type+'...</span>');
						Bandit_Elim.click();
						BUBT = 6;
						setTimeout(function(){Dotravel(DroneX.JobMap[DroneX.EnergySelected].isCity, 'job', DroneX.JobMap[DroneX.EnergySelected].isTab, function(){PreJobChecker();});},3000);
						return;
					}
				}
			}
			setTimeout(function(){ClickJob();},100);
		}
		
		function doSwitch(){
			var DoesIHaveEnergy = parseInt(document.getElementById('user_energy').innerHTML);
			for(var i = (getArrayIndexForKey(DroneX.JobMap, 'isJobID', DroneX.JobMap[DroneX.EnergySelected].isJobID) -1); i > -1; i--) {
				if(DroneX.JobMap[i].isRationOn && combinedEn2xp > DroneX.JobMap[i].RatioVal && DroneX.JobMap[i].isCost <= DoesIHaveEnergy||DroneX.JobMap[i].isNRGSwitchOn && DoesIHaveEnergy > DroneX.JobMap[i].isNRGValue && DroneX.JobMap[i].isCost <= DoesIHaveEnergy){
					log('Switching Jobs...')
					return 'Switch';
				}else if(DroneX.JobMap[i].isCost < DoesIHaveEnergy && !DroneX.JobMap[i].isRationOn && !DroneX.JobMap[i].isNRGSwitchOn){
					log('Switching Jobs...')
					return 'Switch';
				}
			}	
		}
		
		function getArrayIndexForKey(arr, key, val){
			for(var i = 0; i < arr.length; i++){
				if(arr[i][key] == val)
					return i;
			}
			return -1;
		}
		
		function isBandit(){
			if(!DroneX.JobMap[DroneX.EnergySelected].isOldCity){
				if ($('#job-id-' + DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-' + DroneX.JobMap[DroneX.EnergySelected].isJobID).children().children('.bandit-wrapper').length > 0) {
					Bandit_type = $('#job-id-' + DroneX.JobMap[DroneX.EnergySelected].isJobID).children('.job_additional_results').children('#loot-bandit-' + DroneX.JobMap[DroneX.EnergySelected].isJobID).children().children('.bandit-wrapper').children('.bandit-wrapper-inner').children('.bandit-desc').text();
					return true;
				}
			}else{
				return false;
			}
		}
		
		function substr(string, SearchStart, SearchEnd) {
			try {
				var nStartPos = 0
				var nEndPos = 0
				var nStartIndex = 0
				var bUseLastIndex = 0;
				var bIndex, aIndex = string.indexOf(SearchStart, nStartIndex);
				if (aIndex === -1) {
					return false;
				}
				if (bUseLastIndex !== true) {
					bIndex = string.indexOf(SearchEnd, aIndex + Math.max(nStartPos, 1));
				} else {
					bIndex = string.lastIndexOf(SearchEnd);
				}
				if (bIndex === -1) {
					return false;
				}
				aIndex += nStartPos;
				bIndex += nEndPos;
				return string.substr(aIndex, bIndex - aIndex);
			} catch (e) {
				return false;
			}
		}
		
		function crewpostr(){
			crewposted = 0;
			return false;
		}
		
		function ClickJob(){
			if(!DroneX.isRunning){
				return;
			}
			updateStats('JobDone');	
			CloseDoopidPopup();
			var JobToClick;
			if(DroneX.JobMap[DroneX.EnergySelected].isUsingButton) {
				JobToClick = $('#btn_dojob_'+DroneX.JobMap[DroneX.EnergySelected].isJobID);
			}else if(DroneX.JobMap[DroneX.EnergySelected].isOldCity){
				JobToClick = $('#city_job_'+ DroneX.JobMap[DroneX.EnergySelected].isJobID +' > .job_action > a');
			}else{
				JobToClick = $('#job_'+ DroneX.JobMap[DroneX.EnergySelected].isJobID +' > a');
			}
			if (JobToClick == null||JobToClick.length < 1){
				log('job el is null, Reloading Page')
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			JobToClick.click();
			log('Doing Job...')
			setTimeout(PreJobChecker, DroneX.Saving.JobSpeed);
		}
		
		function PreFobChecker(){
			if(!DroneX.isRunning){
				return;
			}
			CloseDoopidPopup();
			log('Pre Checking Job Environment...')
			if (/These loot drops are needed for this job/.test(document.body.innerHTML)) {
				log('Not enough consumables..');
				DroneX.StamMap[DroneX.StaminaSelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			if (/You do not have enough cash to do this job/.test(document.body.innerHTML)) {
				log('Not enough cash..');
				DroneX.StamMap[DroneX.StaminaSelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;		
			}
			if (/There are no secret districts currently open!/.test(document.body.innerHTML)) {
				log('Secret District Appears to of gone walkies..');
				DroneX.StamMap[DroneX.StaminaSelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;		
			}
			if (/- Locked/.test(document.body.innerHTML)) {
				log('Secret District Not unlocked!');
				DroneX.StamMap[DroneX.StaminaSelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;		
			}
			if (/MW: This link has expired. Please reload./.test(document.body.innerHTML)) {
				log('Refreshing Session!');
				DroneX.StamMap[DroneX.StaminaSelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			if (/Your session has timed out. Click any button to resume playing./.test(document.body.innerHTML)) {
				log('Refreshing Session!');
				DroneX.StamMap[DroneX.StaminaSelected].isEnabled = false;
				setTimeout(function(){grabInfoz();},1000);
				return;
			}		
			var onMarketPlace = document.evaluate('//div[contains(@class, "marketplace_controller")]//a[contains(., "ALL ITEMS")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength > 0;
			if(onMarketPlace > 0){
				log('Marketplace Tab, Why i go here..');
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			var DoesIHaveEnergy = parseInt(document.getElementById('user_energy').innerHTML);
			var CurrentSTAM = parseInt(document.getElementById('user_stamina').innerHTML);
			var CurrentXP2LVL = parseInt(document.getElementById('exp_to_next_level').innerHTML);
			var combinedEn2xp = (CurrentXP2LVL/(DoesIHaveEnergy+CurrentSTAM)).toFixed(2);
			if(DoesIHaveEnergy > DroneX.switchNRG+10 && DroneX.Saving.StamFirst != 1){
				setTimeout(function(){grabInfoz();},2500);
				return;
			}
			if(CurrentSTAM < DroneX.StamMap[DroneX.StaminaSelected].isCost){
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			if(DroneX.StamMap[DroneX.StaminaSelected].isJobID != DroneX.StamMap[0].isJobID){
				if(DroneX.StamMap[0].isCost < CurrentSTAM){
					log('changing jobs...');
					setTimeout(function(){grabInfoz();},1000);
					return;
				}
			}
			if(DoesIHaveEnergy == 0){
				log('Waiting for 1 energy so we can do a stamina requiring job');
				setTimeout(function(){check_resources(PreFobChecker);},1000*60);
				return;
			}
			updateStats('FobDone');
			setTimeout(function(){ClickStamJob();},100);
		}
		
		function ClickStamJob(){
			if(!DroneX.isRunning){
				return;
			}
			CloseDoopidPopup();
			var JobToClick = $('#btn_dojob_'+DroneX.StamMap[DroneX.StaminaSelected].isJobID);
			if (JobToClick == null||JobToClick.length < 1){
				log('job el is null, Reloading Page')
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
			JobToClick.click();
			log('Doing Job...')
			setTimeout(PreFobChecker, DroneX.Saving.JobSpeed);
		}
		
		function PreRob(){
			if(!DroneX.isRunning){
				return;
			}
			CloseDoopidPopup();
			var DoesIHaveStam = parseInt(document.getElementById('user_stamina').innerHTML);
			var DoesIHaveEnergy = parseInt(document.getElementById('user_energy').innerHTML);
			if(DoesIHaveEnergy > DroneX.switchNRG+10 && DroneX.Saving.StamFirst != 1){
				setTimeout(function(){grabInfoz();},2500);
				return;
			}
			if(DoesIHaveStam < 25){
				setTimeout(function(){grabInfoz();},2500);
				return;
			}
			var tabtest = document.evaluate('//li[contains(@class, "tab_on")]//a[contains(., "Robbing")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength > 0;
			if (tabtest == 0){
				setTimeout(function(){grabInfoz();},2500);
				return;
			}
			var slotcount = 8;
			for (var i=8; i >=0; i--) {
				AjxRequest('remote/html_server.php?xw_controller=robbing&xw_action=rob&xw_city='+MyLocation()+'&slot='+slotcount, function(msg){
					log('Robbing Slots...');
					DroneX.slotsrobbed++;
					if(msg.indexOf('You are now LEVEL')!=-1) {
						log('Levelup!');
						grab_bonus();
					}
					if(DroneX.slotsrobbed == 9){
						refb();
					}
				});
				slotcount--;
			}
		}	
		
		function refb(){
			if(!DroneX.isRunning){
				return;
			}
			DroneX.slotsrobbed = 0;
			log('Refreshing Board...');
			AjxRequest('remote/html_server.php?xw_controller=robbing&xw_action=refresh', function(msg){
				Dotravel(DroneX.StamMap[DroneX.StaminaSelected].isCity, 'robbing', DroneX.StamMap[DroneX.StaminaSelected].isTab, function(){PreRob();});
			});
		}
		
		function CloseDoopidPopup(){
			var actulevel = $('#user_level').text();
			if (actulevel != DroneX.CurrentLevel && DroneX.LevelupPause == 0){
				DroneX.LevelupPause = 1;
				DroneX.CurrentLevel = $('#user_level').text();
				grab_bonus();
			}
			if(DroneX.Saving.StopAtLvl && DroneX.CurrentLevel >= DroneX.Saving.StopAtLvlNum){
				log('Level to stop at reached!');
				$('#stop').click();
				return;
			}
			if($('.pop_bg').length>0){
				$('.pop_bg').each( function(){
					var id = this.id;
					MW.Popup.hide( id.substr( id.lastIndexOf("_") +1 ) );
				});
			}
		}
		
		function grab_bonus(){
			AjxRequest('xw_controller=levelUpBonus&xw_action=addBonusItem&xw_city='+MyLocation()+'&mwcom=1&no_load=1&xw_client_id=8',function(page){
				DroneX.LevelupPause = 0;
				if (page.indexOf('ERROR 500: response never closed')!=-1) {
					return;
				} else {
					var data = JSON.parse(page.replace(/^(\s\d\s+)/,''));
					updateStats('LvlUps');
					$('#LastLvlUp').html('<span class="good">Level <font color="gold">'+data.user_fields.user_level+'</font> You received: <font color="gold">'+data.bonusName+'</font></span>');
				}
			})
		}
			
		function UpdateConfig(value) {
			var value = parseInt(value);
			value === 0 ? $("#DX_Job_Opts").show() : $("#DX_Job_Opts").hide(), 
			value === 1 ? $("#DX_Fight_Opts").show() : $("#DX_Fight_Opts").hide(), 
			value === 2 ? $("#DX_Robbing_Opts").show() : $("#DX_Robbing_Opts").hide(), 
			value === 3 ? $("#DX_Spending_Opts").show() : $("#DX_Spending_Opts").hide(), 
			value === 4 ? $("#DX_Arena_Opts").show() : $("#DX_Arena_Opts").hide(), 
			value === 5 ? $("#DX_Misc_Opts").show() : $("#DX_Misc_Opts").hide()
		}
		
		$("#DX_Opts").change(function () {
			UpdateConfig(this.value);
		})
		
	//	document.getElementById("DX_Opts").options[1].disabled = "disabled";
		document.getElementById("DX_Opts").options[2].disabled = "disabled";
	//	document.getElementById("DX_Opts").options[3].disabled = "disabled";
	//	document.getElementById("DX_Opts").options[4].disabled = "disabled";
		$('#SpendFirst').prop('selectedIndex', DroneX.Saving.StamFirst);
		$('#DX_Rob_Opts').prop('selectedIndex', DroneX.Saving.RobWhere);
		UpdateConfig(document.getElementById("DX_Opts").selectedIndex);
		
		$('#ADD_SAJobs #SA_10_0').parent().parent().parent().parent().parent().parent().hide()
		$('#ADD_SAJobs #SA_10_3').parent().parent().parent().parent().parent().parent().hide()
		$('#ADD_SAJobs #SA_10_6').parent().parent().parent().parent().parent().parent().hide()
		$('#ADD_MEXJobs #MEX_10_2').parent().parent().parent().parent().parent().parent().hide() 
		$('#ADD_MEXJobs #MEX_10_4').parent().parent().parent().parent().parent().parent().hide() 
		$('#ADD_MEXJobs #MEX_10_7').parent().parent().parent().parent().parent().parent().hide()
		
		if (DroneX.Saving.AutoStart){
			document.getElementById("Dx_AutoStart").checked = true;
		}else {
			document.getElementById("Dx_AutoStart").checked = false;
		}
		if (DroneX.Saving.HWP) {
			document.getElementById("HWP").checked = true;
			clearTimeout(HealOn);
			doHeal();
		}else {
			document.getElementById("HWP").checked = false;
		}
		if (DroneX.Saving.AutopostingCrew){
			document.getElementById("APFC").checked = true;
		}else {
			document.getElementById("APFC").checked = false;
		}
		if (DroneX.Saving.Skippy) {
			document.getElementById("SJNC").checked = true;
		}else {
			document.getElementById("SJNC").checked = false;
		}
		if (DroneX.Saving.Restart){
			document.getElementById("Dx_restart").checked = true;
		}else {
			document.getElementById("Dx_restart").checked = false;
		}
		if (DroneX.Saving.FamXP){
			document.getElementById("Dx_famXP").checked = true;
		}else {
			document.getElementById("Dx_famXP").checked = false;
		}
		
		if (DroneX.Saving.MarathonStat){
			document.getElementById("Dx_MarathonStats").checked = true;
		}else {
			document.getElementById("Dx_MarathonStats").checked = false;
			$('#LvlUps').text(0);
			$('#TotalJobsDone').text(0);
		}
		if (DroneX.Saving.RemoveJobs){
			document.getElementById("Dx_RemoveJob").checked = true;
		}else {
			document.getElementById("Dx_RemoveJob").checked = false;
		}
		if (DroneX.Saving.StopAtLvl){
			document.getElementById("Dx_StopAtLvl").checked = true;
		}else {
			document.getElementById("Dx_StopAtLvl").checked = false;
		}
		if (DroneX.Saving.arenaSA){
			document.getElementById("DXspartacus_switch").checked = true;
		}
		else {
			document.getElementById("DXspartacus_switch").checked = false;
		}
		if (DroneX.Saving.arenaMF){
			document.getElementById("DXspartacus_mobfury").checked = true;
		}
		else {
			document.getElementById("DXspartacus_mobfury").checked = false;
		}
		if (DroneX.Saving.arenaPA){
		document.getElementById("DXspartacus_powerattack").checked = true;
		}
		else {
			document.getElementById("DXspartacus_powerattack").checked = false;
		}
		if (DroneX.Saving.arenaSS){
			document.getElementById("DXspartacus_skipshield").checked = true;
		}
		else {
			document.getElementById("DXspartacus_skipshield").checked = false;
		}
		if (DroneX.Saving.arenaSSA){
			document.getElementById("DXspartacus_skipshield_a").checked = true;
		}
		else {
			document.getElementById("DXspartacus_skipshield_a").checked = false;
		}
		if (DroneX.Saving.arenaBK){
			document.getElementById("DXspartacus_boostkami").checked = true;
		}
		else {
			document.getElementById("DXspartacus_boostkami").checked = false;
		}
		if (DroneX.Saving.arenaSP){
			document.getElementById("DXspartacus_sortplayer").checked = true;
		}
		else {
			document.getElementById("DXspartacus_sortplayer").checked = false;
		}

		/*
		document.getElementById("AddSeconds").onclick = function () {
			AddSecondsCount++;
			AddSecondsCount = (AddSecondsCount > 1) ? 0 : AddSecondsCount;
			switch (AddSecondsCount) {
			case 0:
				AddSec = 'false';
				AddSecondsText = document.getElementById("TimeStampSeconds").innerHTML = "Disabled";
				break;
			case 1:
				AddSec = 'true';
				AddSecondsText = document.getElementById("TimeStampSeconds").innerHTML = "On";
				break;
			}
			return false
		};
		
		document.getElementById("DebugChange").onclick = function () {
			DebugOnOff++;
			DebugOnOff = (DebugOnOff > 1) ? 0 : DebugOnOff;
			switch (DebugOnOff) {
			case 0:
				DebugIt = false;
				DebugText = document.getElementById("DebugGUI").innerHTML = "Disabled";
				break;
			case 1:
				DebugIt = true;
				DebugText = document.getElementById("DebugGUI").innerHTML = "On";
				break;
			}
			return false
		};*/
			
		function logit(msg) {
			setTimeout(function() {
				throw new Error(msg);
			}, 0);
		}
		
		function log(msg) {
			$('#Activity').html(msg);
		}
		
		function writeSettings(){
			localStorage.setItem("DXN", JSON.stringify(DroneX.Saving));
		}
	 
		function readSettings(){
			if (!localStorage.getItem("DXN")) { //no settings
				writeSettings();
			} else {
				var tempsettings = JSON.parse(localStorage.getItem("DXN"));
				if(Object.keys(tempsettings).length != Object.keys(DroneX.Saving).length) { 
					logit('stuff in save isnt right length!')
					writeSettings();
				}else{
					DroneX.Saving = tempsettings;
				}
			}
		}

		function loadCustomJobList(){
			for(var i = 0; i < DroneX.Saving.isHiding.length; i++){
				var temp = DroneX.Saving.isHiding[i].isInfo.split('_');
				if(temp[0] == 'SAFOB'){
	//				$('#customStaminaChoice').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">'+$('#'+DroneX.Saving.isHiding[i].isInfo.substring(6)).parent().parent().parent().parent().text().slice(0,-3)+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="'+DroneX.Saving.isHiding[i].isInfo+'">X</a></span></span>'));
	//				$('#ADD_SAFobs #'+DroneX.Saving.isHiding[i].isInfo.substring(6)).parent().parent().removeClass('green').addClass('red');
	//				$('#ADD_SAFobs #'+DroneX.Saving.isHiding[i].isInfo.substring(6)).text('Remove It');
					$('#ADD_SAFobs #'+DroneX.Saving.isHiding[i].isInfo.substring(6)).click();
				}else if(temp[0] == 'MEXFOB'){
					$('#ADD_MEXFobs #'+DroneX.Saving.isHiding[i].isInfo.substring(6)).click();
				}else if(temp[0] == 'ROB'){
					$('#customStaminaChoice').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">Rob In '+$("#DX_Rob_Opts > option:selected").text()+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="'+DroneX.Saving.isHiding[i].isInfo+'">X</a></span></span>'));
					$('#Rob_').parent().parent().removeClass('green').addClass('red');
					$('#Rob_').text('Remove It');
				}else if(temp[0] == 'LTD'){
					//do nothing cause i have to do some techical stuff to implement this in
					if(SecretDistrictCounter > 0){
						//[{"isInfo":"LTD_9_135_1052","isRatioOn":false,"isRatioVal":"0.00","isNRGSwitchOn":false},
						for (var ii = 0; ii < SecretDistrictCounter; ii++) {
							if(DroneX.SDMap[ii].isTab === DroneX.Saving.isHiding[i].isInfo.split('_')[2]){
								$('#customjobs').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;"> '+DroneX.Saving.isHiding[i].isCheatName+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="'+DroneX.Saving.isHiding[i].isInfo+'">X</a></span></span><a title="Add/Remove Energy Options" id="JobEnergyTill"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="margin:7px;"></a><a title="Add/Remove Ratio Options" id="JobRatios"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/target_daily_take_icon.png" style="margin:4px;"></a><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:330px;float:left;">Change to next job when energy is under:<input type="integer" style="resize:none;width:50px;" value="0"></span><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:291px;float:left;">Change to next job when ratio is under:<input type="integer" style="resize:none;width:30px;" value="0.00"></span>'));
								if(DroneX.Saving.isHiding[i].isRatioOn){
									$('#customjobs li span span #'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().children().last().css('display', 'block')
									$('#customjobs li span span #'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().children().last().children('input').val(DroneX.Saving.isHiding[i].isRatioVal)
								}else if(DroneX.Saving.isHiding[i].isNRGSwitchOn){
									$('#customjobs li span span #'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().children().last().prev().css('display', 'block')
									$('#customjobs li span span #'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().children().last().prev().children('input').val(DroneX.Saving.isHiding[i].isNRGValue)
								}
							} 
						}
					}
				}else{
	//				$('#customjobs').append($('<li style="clear:both;list-style-type: none;height:36px;"></li>').html('<span style="background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:524px;float:left;">'+$('#'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().parent().text().slice(0,-3)+' <span style="float:right;margin:3px;"><a href="#" class="clearitem" id="'+DroneX.Saving.isHiding[i].isInfo+'">X</a></span></span><a title="Add/Remove Energy Options" id="JobEnergyTill"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/inventory/NAV/Inventory-wishlist-icon.png" style="margin:7px;"></a><a title="Add/Remove Ratio Options" id="JobRatios"><img src="https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/v3/target_daily_take_icon.png" style="margin:4px;"></a><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:330px;float:left;">Change to next job when energy is under:<input type="integer" style="resize:none;width:50px;" value="0"></span><span style="display:none; background: none repeat scroll 0 0 #111111;border: 1px solid #333333;height: 24px;width:291px;float:left;">Change to next job when ratio is under:<input type="integer" style="resize:none;width:30px;" value="0.00"></span>'));
	//				$('#'+DroneX.Saving.isHiding[i].isInfo).parent().parent().removeClass('green').addClass('red');
	//				$('#'+DroneX.Saving.isHiding[i].isInfo).text('Remove It');
					$('#'+DroneX.Saving.isHiding[i].isInfo).click();
					if(DroneX.Saving.isHiding[i].isRatioOn){
						$('#customjobs li span span #'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().children().last().css('display', 'block')
						$('#customjobs li span span #'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().children().last().children('input').val(DroneX.Saving.isHiding[i].isRatioVal)
					}else if(DroneX.Saving.isHiding[i].isNRGSwitchOn){
						$('#customjobs li span span #'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().children().last().prev().css('display', 'block')
						$('#customjobs li span span #'+DroneX.Saving.isHiding[i].isInfo).parent().parent().parent().children().last().prev().children('input').val(DroneX.Saving.isHiding[i].isNRGValue)
					}
				}
			}
		}loadCustomJobList();
		
		function SpendSkillCycle() {
	//		logit('zxczxc')
	//		if(!ManualSpend){
				if(!DroneX.isRunning){
					return;
				}
	//		}
			if(DroneX.Saving.SkillToSpend == 'none'||!SkillPointAssinRunning){
	//			ManualSpend = false;
				SkillPointAssinRunning = false;
				return;
			}
			var url;
			var SkillPointNum;
			if(SPAvaiable >= 5 && SPAvaiable < 25){
				url = 'xw_controller=stats&xw_action=upgrade&xw_city=7&upgrade_key='+DroneX.Saving.SkillToSpend+'&upgrade_amt=5&no_load=1&source=level_up_popup';
			}else if(SPAvaiable >= 25 && SPAvaiable < 100){
				url = 'xw_controller=stats&xw_action=upgrade&xw_city=7&upgrade_key='+DroneX.Saving.SkillToSpend+'&upgrade_amt=25&no_load=1&source=level_up_popup';
			}else if(SPAvaiable >= 100){
				url = 'xw_controller=stats&xw_action=upgrade&xw_city=7&upgrade_key='+DroneX.Saving.SkillToSpend+'&upgrade_amt=100&no_load=1&source=level_up_popup';
			}else{
				url = 'xw_controller=stats&xw_action=upgrade&xw_city=7&upgrade_key='+DroneX.Saving.SkillToSpend+'&upgrade_amt=1&no_load=1&source=level_up_popup';
			}
			if(url.match(/&upgrade_amt=5/g)){
				SkillPointNum = '5 Skillpoints';
			}else if(url.match(/&upgrade_amt=25/g)){
				SkillPointNum = '25 Skillpoints';
			}else if(url.match(/&upgrade_amt=100/g)){
				SkillPointNum = '100 Skillpoints';
			}else if(url.match(/&upgrade_amt=1&/g)){
				SkillPointNum = '1 Skillpoint';
			}
			AjxRequest(url, function(msg){
	//			if(!ManualSpend){
					if(!DroneX.isRunning){
						return;
					}
	//			}
				$('#Activity').html('<span class="good">Applied <font color="gold">'+SkillPointNum+'</font> to:</span> <font color="gold">'+SkillsTo+'</font>');
				try{
					var data = JSON.parse(msg);
					user_fields_update(data.user_fields);
					user_info_update(data.user_fields, data.user_info);
					SPAvaiable = parseInt(data.user_fields.user_skill);
					if(SPAvaiable == 0){
						SkillPointAssinRunning = false;
						setTimeout(function(){grabInfoz();},1000);
						return;
					}else{
						SpendSkillCycle();
					}
				}catch(errz){
					setTimeout(function(){SpendSkillCycle();},1000);
				}
			});
		}
		
		function familyXPCollector(){
			familyXPMasteryStage = 0;
			familyXPTypeStage = 0;
			for(var i = 0; i < 12; i++){
				familyXPTypeStage = i % 4;
				familyXPMasteryStage = (i - (i % 4)) / 4;
				var famXpElement = document.getElementById(familyXPTypes[familyXPTypeStage])
				if(famXpElement != null && famXpElement.className.indexOf("complete") > -1){
					var famXpCollectButton = famXpElement.getElementsByClassName("collect_button")[0];
					var famXpCollectUrl = famXpElement.getElementsByTagName("a")[0];
					famXpCollectUrl = famXpCollectUrl.href;
					if(famXpCollectButton != null && famXpCollectUrl != null && famXpCollectButton.style.display != "none" && famXpCollectButton.innerHTML.indexOf(familyXPMastery[familyXPMasteryStage]) > -1){
						AjxRequest(famXpCollectUrl, function (response) {
							var response = JSON.parse(response);
							if (response.success) {
								log('<span class="'+response.star_class+'"></span>'+response.msg);
							}else {
								log('<span class="bad">Failed to collect '+response.exp_type+'!</span> <span class="more_in">(Already collected or not ready?)</span>');
								setTimeout(function(){check_resources(grabInfoz);},1000);
								return;
							}
							if (Util.isset(response.clanXp)) {
								user_fields_update(response.user_fields);
								user_info_update(response.user_fields, response.user_info);
							}
							else {
								var QuestBar = JSON.parse(/MW.QuestBar.update\((.*)\);/.exec(response)[1]);
							}
							MW.QuestBar.collectClanXpCallback(response);
							setTimeout(function(){Dotravel(10, 'homeit', 'homeit', function(){check_resources(grabInfoz);});},2000);
						});
						return;
					};
				};
			};
			log('No family XP to collect...');
			setTimeout(function(){check_resources(grabInfoz, 'true');},1000);
		};

		if (DroneX.Saving.AutoStart){
			$('#DxAS').show();
			LoadDroneXJobList();
			ClickGo = setTimeout(function(){autorunDx();},15000);
		}
		
		$('#DxAS').click(function(){
			clearTimeout(ClickGo);	
			$('#DxAS').hide();
			return false;
		})
		
		$('#ResetCounters').click(function(){
			$('#LvlUps').text(0);
			$('#TotalJobsDone').text(0);
			clearTimeout(ClickGo);	
			$('#DxAS').hide();
			return false;
		})
		
	/*	$('#SpendSkillsNow').click(function(){
		logit(DroneX.isRunning)
		logit(SkillPointAssinRunning)
			if(!DroneX.isRunning && !SkillPointAssinRunning){
				logit('asdasd')
				SkillPointAssinRunning = true;
				ManualSpend = true;
				SpendSkillCycle();
			}
			return false;
		})	*/
		
		function autorunDx(){
			if (DroneX.Saving.AutoStart){
				$("#start").click()
			}else{
				return;
			}		
		}
		
		function displayTime(extra) {
			var addTime = parseInt(extra);
			var str = "";

			var currentTime = new Date()
			var hours = currentTime.getHours()
			var minutes = currentTime.getMinutes()
			var seconds = currentTime.getSeconds()
			
			minutes = minutes+addTime;
			
			if (minutes < 10) {
				minutes = "0" + minutes
			}
			if(minutes > 59){
				minutes = 60 - minutes;
				minutes = "0" + Math.abs(minutes);
				hours = hours+1;
			}
			if (seconds < 10) {
				seconds = "0" + seconds
			}
			str += hours + ":" + minutes + ":" + seconds + " ";
			if(hours > 11){
				str += "PM"
			} else {
				str += "AM"
			}
			return str;
		}
			
		$('#close').click(function(){
			clearTimeout(HealOn);
			window.stop();
			arena_running = false;
			try {
				socke.close();
			} catch(noopenedyet) {}
			try {
				socke_lobby.close();
			} catch(noopenedyet) {}
			$('#gxDiv').remove();
		});
			
		/*add analytics*/
		function loadContent(file) {
			var head=document.getElementsByTagName('head').item(0);
			var scriptTag=document.getElementById('loadScript');
			if(scriptTag)head.removeChild(scriptTag);
			script=document.createElement('script');
			script.src=file;
			script.type='text/javascript';
			script.id='loadScript';
			head.appendChild(script);
			setTimeout(load,1000);
		}
		loadContent('http://www.google-analytics.com/ga.js');
		function load() {
			try {
				var pageTracker=_gat._getTracker("UA-35022618-1");
				pageTracker._trackPageview("/DroneX V"+DroneX.Version);
			} catch(err){}
		}
		/*end analytics*/
		
		//below the line;
	var powUrl = "";
	var stopPreRedFighting = false;	
	var redAttacks = 0;
	var damage = 0;
	var iced = 0;
	var killed = 0;
	var stolen = 0;
	var targetIced = false;
	var oponentImages = [];
	var oponentNames = [];
	var targetHealth = 100;
	var requestCount = 0;
	var startFL = 1;
	var Fateler0z = 0;	
	
	function goRedFightTab(){
		if(!DroneX.isRunning){
				return;
		}
		if(DroneX.Saving.mwId == 0){
			log('Player to attacks PID is invalid');
			$('#stop').click();
			return;
		}
		stopPreRedFighting = true;
		powUrl = "";
		redAttacks = 0;
		damage = 0;
		Dotravel(DroneX.Saving.FightCity, 'fight', 1, function(){doRedFights();});
	};
	
	function doRedFights(){
		if(!DroneX.isRunning){
				return;
		}
		var onMarketPlace = document.evaluate('//div[contains(@class, "marketplace_controller")]//a[contains(., "ALL ITEMS")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength > 0;
		if(onMarketPlace > 0){
			log('Marketplace Tab, Why i go here..');
			setTimeout(function(){grabInfoz();},1000);
			return;
		}
		var DoesIHaveEnergy = parseInt(document.getElementById('user_energy').innerHTML);
		var CurrentSTAM = parseInt(document.getElementById('user_stamina').innerHTML);
		var CurrentXP2LVL = parseInt(document.getElementById('exp_to_next_level').innerHTML);
		var combinedEn2xp = (CurrentXP2LVL/(DoesIHaveEnergy+CurrentSTAM)).toFixed(2);
		if(DoesIHaveEnergy > DroneX.switchNRG+10 && DroneX.Saving.StamFirst != 1){
			setTimeout(function(){grabInfoz();},2500);
			return;
		}
		if(CurrentSTAM < DroneX.StamMap[DroneX.StaminaSelected].isCost){
			setTimeout(function(){grabInfoz();},1000);
			return;
		}
		if(DroneX.StamMap[DroneX.StaminaSelected].isJobID != DroneX.StamMap[0].isJobID){
			if(DroneX.StamMap[0].isCost < CurrentSTAM){
				log('changing jobs...');
				setTimeout(function(){grabInfoz();},1000);
				return;
			}
		}
		if(parseInt($('#user_health').text()) < 25){
			log('no health');
			$('#stop').click();
			return;
		}
		/*if(parseInt($('#user_stamina').text()) < 75){
			log('stamina under 75');
			$('#stop').click();
			return;
		}*/
		var whitebuttons = document.getElementsByClassName('sexy_button_new short white');
		var attackButton = document.getElementById('btn_attack_p'+DroneX.Saving.mwId); 
		var fightWrapper = document.getElementById('fv2_widget_wrapper');
		if(targetIced){
			targetIced = false;
			setTimeout(function(){Dotravel(DroneX.Saving.FightCity, 'fight', 1, function(){doRedFights();})},5000);
			log('Player is Iced/Killed, Rechecking...')
			return;
		};
		var fightSpeed = $('#Dx_AttSpd').val();
		if(targetHealth < 30){
			fightSpeed = 5 * 500;
		};
		if(whitebuttons.length > 0){
			for(var i = 0; i < whitebuttons.length; i++){
				if(whitebuttons[i] != null && whitebuttons[i].href != null && whitebuttons[i].href.indexOf('xw_action=remove_and_fight') > -1){
					log('Removing player '+ DroneX.Saving.mwId);
					whitebuttons[i].click();
					setTimeout(goRedFightTab, 5000);
					return;
				};
			};
		};
		redAttacks++;
		if((redAttacks % 200) == 0){
			log('Refreshing fight page to keep tmp keys current');
			setTimeout(goRedFightTab, 3000);
			return;
		};
		if((redAttacks % 10) == 0){
			var CurrCity = /mw_city(\d+)/.exec(document.getElementById('mw_city_wrapper').className)[1]; //= 10;
			do_ajax('inner_page', 'remote/html_server.php?xw_controller=fight&xw_action=view&xw_city=' + CurrCity+'&tab=1', 1, 1, 0, 0);
		};
		if(fightWrapper != null && fightWrapper.style.display != 'none'){
			addPlayerToOponents();
		};
		log('Attacking player: p|'+ DroneX.Saving.mwId +', @ Speed='+ fightSpeed+'ms');
		if(powUrl != ""){
			AjxRequest(powUrl, parseAttack, parseError);
			setTimeout(doRedFights, fightSpeed);
			return;
		};
		if(attackButton != null){
			var isalive = $('#btn_attack_p'+DroneX.Saving.mwId).parent().parent().children(0).attr('class');
			if(isalive == 'fight_list_player_dead'){
				setTimeout(function(){Dotravel(DroneX.Saving.FightCity, 'fight', 1, function(){doRedFights();})},5000);
				log('Player is Iced/Killed, Rechecking...')
				return;
			}else{
//				logit(attackButton)
				attackButton.click();
				setTimeout(doRedFights, 5000);
				return;
			}
		}else{
			var fightlist = document.getElementsByClassName('action');	
			for(var i = startFL; i < fightlist.length; i++){
				try{
					fightlist[i].firstElementChild.href = fightlist[i].firstElementChild.href.replace(/opponent_id=p%7C\d+/,'opponent_id=p%7C'+DroneX.Saving.mwId);
					attackButton = fightlist[i].firstElementChild.href;
//					logit(attackButton)
//					i_fight.targetlink = i_fight.targetlink.substr(i_fight.targetlink.indexOf('?')+1);
					break;
				}catch(pagenull){
					if(Fateler0z > 2){
						logit('Er0z? '+i)
						logit('Er0z? '+fightlist.length)
						$('#stop').click();
						return;
					}
					startFL++;
					Fateler0z++;
					doRedFights();
					return;
				}
			}
			startFL = 1;
			Fateler0z = 0;
			attackButton.click();
			setTimeout(doRedFights, 5000);
		};
	};
	
	function addPlayerToOponents(){
		var fightWrapper = document.getElementById('fv2_widget_wrapper');
		fightWrapper.style.top = "600px";
		var fightButtons = fightWrapper.getElementsByClassName('fightV2AttackBtn')[3];
		powUrl = fightButtons.getAttribute('href');
		powUrl = powUrl.replace("click_amt=1", "click_amt="+DroneX.Saving.Bursts);
		oponentId = /opponent_id=p%7C(\d+)&/.exec(powUrl)[1];
		powUrl = powUrl.replace("use_boost=1", "use_boost=0");
		fightWrapper.style.display = "none";
		var fightv2Widget = document.getElementById('fv2_widget_spacer');
		if(fightv2Widget != null){
			fightv2Widget.style.display = "none";
		};
		var fightv2DefenderWrapper = document.getElementById('wrapper_defender');
		var fightv2DefenderHref = fightv2DefenderWrapper.getElementsByTagName('a');
		var DefenderImg = $('#defender_pic img').attr('src');
//		var DefenderBadge = $('#defender_badge fight_badge').attr('src'); //<img src="'+DefenderBadge+'" style="width: 25px; height: 25px;" />
		var OpStatus = '<span style="color:green;font-weight:bold">ALIVE</span>';
		var fightOverLay = fightWrapper.getElementsByClassName('fv2_iced_overlay');
		for(var i = 0; i < fightOverLay.length; i++){
			if(fightOverLay[i] != null && fightOverLay[i].style.display == "block"){
				OpStatus = '<span style="color:red;font-weight:bold">DEAD</span>';
			};
		};
		var fightv2ResultDiv = fightWrapper.getElementsByClassName('fightV2_result');
		var fightResultImg = fightv2ResultDiv[0].getElementsByClassName('img');
		if(fightResultImg != null && fightResultImg.src != null){
			if(fightResultImg.src.indexOf('youwin') == -1){
				OpStatus = '<span style="color:red;font-weight:bold">LOST :(</span>';
			};
		};
		if(document.getElementById('newfightx'+ oponentId) == null){
			var OpDiv = '<tr id="newfightx'+ oponentId +'" opId="'+ oponentId +'">' + '<td width="60">Attacking:</td>' + '<td width="25"><img src="'+ DefenderImg +'" style="width: 25px; height: 25px;" /> </td>' + '<td>';
			if(fightv2DefenderHref[0].innerHTML.indexOf(':red') > -1){
				oponentNames[oponentId] = fightv2DefenderHref[0].innerHTML +'&nbsp;';
				OpDiv += '<a  class="mw_new_ajax" selector="#inner_page" href="'+ fightv2DefenderHref[0].href +'">' + fightv2DefenderHref[0].innerHTML + '</a>';
			};
			oponentImages[oponentId] = DefenderImg;
			oponentNames[oponentId] += fightv2DefenderHref[1].innerHTML;
			OpDiv += '<a  class="mw_new_ajax" selector="#inner_page" href="'+ fightv2DefenderHref[1].href +'">' + fightv2DefenderHref[1].innerHTML + '</a>' + '</td>' + '<td>' +'&nbsp;' + '</td>' + '<span id="newfightx'+ oponentId +'_Status" width="90">'+ OpStatus + '</span>'+' Iced: <span id="newfightx'+ oponentId +'_Iced" width="90">0</span> Killed: <span id="newfightx'+ oponentId +'_Killed" width="90">0</span> Stolen: <span id="newfightx'+ oponentId +'_Stolen" width="90">0</span></tr>';
			document.getElementById('newfightx').innerHTML = OpDiv;
		};
	};
	
	function parseAttack(response){
		if(!DroneX.isRunning){
				return;
		}
		if(response == null){
			return;
		};
		if(/&o=p%7C(\d+)&/.exec(response) == null){
			return;
		};
		var OpId = /&o=p%7C(\d+)&/.exec(response)[1];
		if(damage == null){
			damage = 0;
		};
		var data = JSON.parse(response);
		if(data == null){
			return;
		};
		if(data.user_fields != null){
			document.getElementById('user_stamina').innerHTML = data.user_fields.user_stamina;
			document.getElementById('user_energy').innerHTML = data.user_fields.user_energy;
			document.getElementById('user_health').innerHTML = data.user_fields.user_health;
			document.getElementById('exp_to_next_level').innerHTML = data.user_fields.exp_to_next_level;
		};
		if(data.fight_result != null){
			var fightResult = "";
			if(data.fight_result.power_attack != null){
				if(data.fight_result.power_attack.lost > 0){
					fightResult += '<span style="color:red;font-weight:bold">LOST</span>';
				}else{
					fightResult += '<span style="color:green;font-weight:bold">WON</span>';
				};
				fightResult += 'Fight: '+ (data.fight_result.power_attack.lost + data.fight_result.power_attack.won) +', ';
			};
			targetIced = false;
			targetHealth = 100;
			if(data.fight_result.defender != null){
				if(data.fight_result.defender.damage_dealt > 40){
					damage += data.fight_result.defender.damage_dealt;
				};
				targetHealth = parseInt(data.fight_result.defender.current_health_pct);
				var targetHealthPercent = '<span style="color:green">Health: '+ data.fight_result.defender.current_health_pct +'%</span>';
				if(targetHealth != 0){
					document.getElementById('newfightx'+ OpId +'_Status').innerHTML = targetHealthPercent;
				};
				var DamageRecieved = 'D: ' + data.fight_result.defender.damage_dealt +'('+ damage +'), ';
				document.getElementById('newfightx' + OpId +'_Status').innerHTML = DamageRecieved;
				if(data.fight_result.defender.other_damage > 0){
					fightResult += 'Others: ' + data.fight_result.defender.other_damage + '% ';
				};
				log(fightResult)
				if(data.fight_result.defender.is_iced == true || data.fight_result.defender.was_iced == true || data.fight_result.defender.is_killed == true || data.fight_result.defender.iced_self == true || data.fight_result.defender.you_iced == true){
					targetIced = true;
				};
			};
			if(data.fight_result.you_just_iced == true){
				iced++;
				targetIced = true;
				document.getElementById('newfightx'+ OpId +'_Status').innerHTML = '<span style="color:red;font-weight:bold">ICED</span>';
				updateStats('newfightx'+ oponentId +'_Iced')
//				var _0xe357x98 = parseFeedJS(data.fight_result.feed_js);
//				addIceLog(_0xe357x98, "orange");
			};
			if(data.fight_result.you_just_killed == true){
				killed++;
				targetIced = true;
				document.getElementById('newfightx'+ OpId +'_Status').innerHTML = '<span style="color:red;font-weight:bold">KILLED</span>';
				updateStats('newfightx'+ oponentId +'_Killed')
//				var _0xe357x98 = parseFeedJS(data.fight_result.feed_js);
//				addIceLog(_0xe357x98, "white");
			};
			if(data.fight_result.ice_was_just_stolen == true){
				targetIced = true;
				document.getElementById('newfightx'+ OpId +'_Status').innerHTML = '<span style="color:red;font-weight:bold">STOLEN</span>';
				if(damage > 0){
					damage = 0;
					stolen++;
					var StolenBy = 'Ice Stolen by ' + data.fight_result.thief_class + ' ' + data.fight_result.thief_name;
					updateStats('newfightx'+ oponentId +'_Stolen')
					log(StolenBy)
//					addIceLog(StolenBy, "gray");
				};
			};
			if(targetIced == true){
				damage = 0;
				var CheckforRed = document.getElementById('newfightx'+ OpId +'_Status').innerHTML;
				if(CheckforRed.indexOf(':red') == -1){
					document.getElementById('newfightx'+ OpId +'_Status').innerHTML = '<span style="color:red;font-weight:bold">DEAD</span>';
				};
			};
		};
	};
	
	function parseError(response){};
	
	function doHeal(){
		if(!DroneX.Saving.HWP){
			return;
		}
		var clock_healthelt = document.getElementById('clock_health');
		var healelt = xpathFirst('.//a[contains(., "Hospital")]', clock_healthelt) || xpathFirst('.//a[contains(., "Morgue")]', clock_healthelt);
		var healthelt = document.getElementById('stat_health');
		var hospital_url = healelt.href;
		var healurl = healelt.href.replace("xw_action=view", "xw_action=heal");
		healurl = healurl.replace("xw_controller=index", "xw_controller=hospital");
		healurl = healurl + '&xcity=1';
		AjxRequest(healurl, function (msg) {
			if (msg.indexOf('ERROR 500: response never closed')!=-1) {
				HealOn = setTimeout(function(){doHeal();},2500);
				return;
			}
			var a =	parseInt(JSON.parse(msg).user_fields.user_health);
			document.getElementById('user_health').innerHTML = a;
			var b = JSON.parse(msg).waitHealTimer;
			if(b < 0){
				b = 40;
			}
			b = b*1000;
			var c = JSON.parse(msg).hospital_message;
            if (/The doctor healed/.test(c)) {
//				log(c);
            }
			HealOn = setTimeout(function(){doHeal();},b);	
		});
	}
	
	function xpathFirst(p, c) {
		return document.evaluate(p, c || document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
	}
	
	$('.DXspartacus_att').click(function(){
		attack($(this).attr('data-id'),1);
		return false;
	});
	$('#DXspartacus_toggleloot').click(function(){
		$('.DXspartacus_lootlog').toggle();
		//write_loot();
		return false;
	});
	$('#DXspartacus_togglearenas').click(function(){
		$('.DXspartacus_arenalog').toggle();
		//write_loot();
		return false;
	});
	$('#DXspartacus_restart_stam').change(function(){
		if(this.checked) {
			$('#DXspartacus_show_restart_stam').show();
		} else {
			$('#DXspartacus_show_restart_stam').hide();
		}
	}).trigger('change');
	$('#DXspartacus_stopon').change(function(){
		if(this.selectedIndex>1) {
			$('#DXspartacus_show_stopon_value').show();
		} else {
			$('#DXspartacus_show_stopon_value').hide();
		}
	}).trigger('change');
	
/*	$('.DXspartacus_conf input,select').change(function(){
		writeSettings();
		save_config();
	});*/

	$('#DXspartacus_table').hover(function(){
		over_table = true;
		$('#DXspartacus_table').css('border-color','#444');
		$('#DXspartacus_lockrank').show();
	},function(){
		over_table = false;
		$('#DXspartacus_table').css('border-color','black');
		$('#DXspartacus_lockrank').hide();		
	});
	
	function update_crests(){
		AjxRequest('xw_controller=lobby&xw_action=play',function(resp){
			var $page = $('<div>'+resp+'</div>');
			var crests = parseInt($page.find('.mastery_stat_cont').find('.respect_value').text());
			var output = '';
			if(!isNaN(crests)){
				if(last_crests){
					output += crests+'<span class="good">(+'+(crests-last_crests)+')</span>';
				}
				else{
					output += crests;
					last_crests = crests;
				}
			}
			$('#DXspartacus_crests').html(output);
		},$.noop)
	}update_crests();

	function write_arenas(){
		var i,score,html='';
		for(i=0;i<arenalist.length;i++){
			var type,arena=arenalist[i];
			if (arena.opponents > 2) {
				type = 'Rank: '+arena.rank+" of "+arena.opponents;
				score = 'Score: '+arena.points;
			}
			if (arena.opponents < 3) {
				type = (arena.rank==1?'Won':'Lost')+" against "+arena.opponentname;
				score = 'Score: '+arena.points;
			}
			if (arena.type == 'mobfury') {
				type = 'MobFury '+(arena.rank==1?'Victory':'Loss');
				score = 'Red: '+arena.teamred+' vs Blue: '+arena.teamblue;
			}
			html += 'Arena #'+(i+1)+' '+type+', '+score+', Stamina: '+arena.stam+(arena.crests?', Crests:'+arena.crests:'')+' [<a href="#" data-id="'+i+'" '+$c('brag')+'" >Brag</a>]';
			html+='<br />';
		}
		$('#DXspartacus_arenalog').html(html);
	}

	
	function startarena(){
		set_progress_bar(0,0,'');	
		log('<span class="bad">Not started yet!</span>');
		if(!arena_running) {
			arena_running = true;
			//check_skills(join_arena);
			join_arena();
		}
	}
	
	function set_progress_bar(value,of,text){
		var pc=100-parseInt(value/of*100);
		if(pc<0) { pc=0; }
		if(pc>100) { pc=100; }
		
		if($('#spartacusbar').length>0) {
			$('#spartacusbar > div').css('width',pc+'%');
			$('#spartacusbar p').text(text);

			if(pc>=88) {
				$('#spartacusbar').removeClass('gold').addClass('ruby');
			} else {
				$('#spartacusbar').removeClass('ruby').addClass('gold');
			}
		} else {
			$('#DXspartacus_timeleftbar').html(''+
				'<div class="bossInfo">'+
				'<div style="position:relative; height:25px; ">'+
				'<div id="spartacusbar" class="progressBar gold dark_border" style="width:488px; float:left;">'+
				'<div style="width: '+pc+'%;"></div><p style="text-align:center;">'+text+'</p>'+
				'<div style="width: '+pc+'%;"><p style="text-align:center;color:#FFFFFF;">'+text+'</p></div></div>'+
				'</div>'+
				'<div class="progBackground" style="display: none;"></div>'+
				'<div class="clearfix" style="clear:both;"></div></div>');
			}
	}

	function join_arena() {
		//check if Spartacus is still running
		if ($('#gxRDivS').length == 0) {
			arena_running = false;
			return;
		}
		/* initialize vars */
		cmdqueue=[];
		meid=null;
		meteam=null;
		poweratt = undefined;
		poweruplist = {};
		playerinfo={};
		playerids={};
		stam_on_start = -1;
		powerup_status = {};
		powerup_command = { count:{},active:-1,target:undefined };
		da_game = [];
		protect = {};
		$('span[id*="DXspartacus_rank"]').html('');
		$('span[id*="DXspartacus_pu"]').html('');
		$('span[id*="DXspartacus_name"]').html('');
		$('span[id*="DXspartacus_respect"]').html('');
		$('span[id*="DXspartacus_diff"]').html('');
		$('span[id*="DXspartacus_health"]').html('');
		$('span[id*="DXspartacus_score"]').html('');
		$('span[id*="DXspartacus_usepu"]').html('');
		/* join */
		log('Joining arena...');
		var DoesIHaveStamina = parseInt(document.getElementById('user_stamina').innerHTML);
		if(DoesIHaveStamina == 0){
			DoesIHaveStamina = parseInt($('#arena_me_st').text());
		}
		var type = ArenaReq;
		if(DroneX.Saving.arenaSAO && DoesIHaveStamina <= DroneX.Saving.arenaSAV) {
			log('Switched arenas to 100 stamina ones...');
			type = "lw";
		}
		replenish=(type=="sw"?2:(type=="lw"?10:50));
		$('#DXspartacus_replenish').text(replenish);
		var gametype = '';
		if($('#DXspartacus_mobfury').is(':checked')) { gametype = '&arenaGameType=2'; }
		AjxRequest('xw_controller=Lobby&xw_action=join_arena&arenaType='+type+gametype+'&xw_client_id=8',function(msg){
			//console.log(msg);
			var json = JSON.parse(msg);
			if(json.data.success == 1) {
				arena_running = true;
				if(json.data.message=="User is in another arena") {
					log('Successfully re-joined Arena.');
				} else {
					log('Successfully joined Arena.');
				}
				$('#user_stamina').text('0');
				load_arena();
			}
			else {
				if (json.data.message.indexOf('Refresh to claim your rewards from the previous Arena')!=-1) {
					log('Claiming your rewards from the previous Arena');
					get_rewards();
				}
				else if(json.data.message.indexOf('have enough stamina to join this arena')!=-1) {
					log('Not enough Stamina, stopping.');
					$('#DXspartacus_table').html(optable);
					arena_running = false;
					setTimeout(function(){grabInfoz();},1000);
					return;
				}
				else if(json.data.message.indexOf('Unable to join')!=-1) {
					var wait = Math.floor(Math.round((Math.random() * 8))+2);
					log('Unable to join this Arena. Join another one. Trying again in '+wait+'s...');
					setTimeout(join_arena,wait*1000);
				}
				else {
					log('Could not join, msg='+json.data.message);
					arena_running = false;
					setTimeout(function(){grabInfoz();},1000);
					return;
				}
			}

		},function(){
			log('Error on trying to join arena, retrying in 30 seconds...');
			arena_running = false;
			setTimeout(function(){grabInfoz();},1000);
			return;
			// script ends here
		});
	}
	
	function load_arena(){
		AjxRequest('xw_controller=Lobby&xw_action=loadArena&xw_client_id=8&exit=t',function(msg){
			var m;
			if(m = /viewObj.init\(\"([^\"]*)\",/.exec(msg)) {
				var wslink = m[1];
				connect_arena(wslink);
			}
			if (m = /MW.lobbyViewObj.getSendMsg\(\'([\d\,]+)\', \'([^\']*)\'/.exec(msg)) {
				if(socke_lobby && m[1]) {
					socke_lobby.send('{"Id":'+User.id.substr(2)+',"Cmd":"sendMsg","Args":["'+m[1]+'"],"Extra":["'+m[2]+'"]}');
				}
			}
		},function(){
			log('Error on trying to load');
			load_arena()
		});
	}
	
	function connect_arena(sockenurl) {
		socke=new WebSocket(sockenurl);
		socke.onopen=function(){
			log('Connected to Arena.');
			$('#DXspartacus_table').html(optable);
			conn_checker = setInterval(check_connection,100);
			reconnect_retry = 0;
		};
		socke.onmessage=function(msg){
			var json=JSON.parse(msg.data);
			try {
				if((json.mi.ammo==-1) && (json.ac)) {
					if(json.ac.substr(0,1)=="2") {
						if(json.ac.substr(2,1)=="1") {
							log('Successfully escaped! Brave Sir Robin ran <a href=\"http://www.youtube.com/watch?v=BZwuTo7zKM8&feature=player_detailpage#t=59s\" target=\"_blank\">away away!</a>');
							// give me my stamina back!
							AjxRequest('xw_controller=lobby&xw_action=leaveArena&xw_city=&xw_person=&xw_client_id=8',function(){
								log('Stamina retrieved.');
								$('#DXspartacus_stage').html('Waiting for Start.');
							});
						} else {
							log('Could not leave, too late. You are trapped in here, good luck.');
						}
					}
				}
			} catch(all) {console.log(all);}
			
			update_info(json);
			decide_actions();
			send_queue();


		};
		socke.onclose=function(){
			last_update=0;
			//log('Disconnected');
			clearInterval(conn_checker);
			$('#DXspartacus_connstatus').html('-');
			set_progress_bar(0,0,'');
			
			if(currdata && (currdata.s==2)) {
				console.log(currdata);
				try {
					if((currdata.s<1) && (currdata.mi.ammo==-1)){
						arena_running = false;
						return;
					}
				} catch(all) {console.log(all);}
			
				reconnect_retry++;
				if(currdata.t<3) {
					log('Connection closed in the last seconds, might be normal. Claiming rewards in a few...');
					setTimeout(get_rewards, currdata.t*2000);
				} else if(reconnect_retry>5) {
					log('Lost connection 5 times in a row, not retrying again.');
				} else {
					log('Probably lost connection, reconnecting');
					join_arena();
				}
			} else if (currdata.s==4) {
				log('Closed connection, challenge decline or expired.');
				// give me my stamina back!
				AjxRequest('xw_controller=lobby&xw_action=leaveArena&xw_city=&xw_person=&xw_client_id=8',function(){
					log('Stamina retrieved.');
					$('#DXspartacus_stage').html('Waiting for Start.');
					arena_running = false;
				});	
			}
			else
			{
				reconnect_retry = 0;
				get_rewards();
			}
		};
	}	
	
	function check_connection(){
		if(!arena_running) {
			clearInterval(conn_checker);
		}
		if(last_update>0){
			var res,gap=(new Date()).getTime()-last_update;
			if(gap<600) {
				res='<span class="good">Good!</span>';
			} else if(gap<1200) {
				res='<span style="color:orange;font-weight:600;">Slow...</span>';
			} else {
				res='<span class="bad">Stalled!</span>';
			}
			$('#DXspartacus_connstatus').html(res);
		}
	}
	
	
	function get_rewards(handler) {
		// log('Retrieving rewards...');
		AjxRequest('xw_controller=Arena&xw_action=rewards&xw_client_id=8',function(msg){
			parse_loot(msg);
			setTimeout(function(){ getStats(displayMafiaStats); },2000);
			arena_running = false;
		});
	}

	function delayArenaChk(){
		var DoesIHaveStamina = parseInt($('#arena_me_st').text());
		var DoesIHaveEnergy = parseInt(document.getElementById('user_energy').innerHTML);
		if(DoesIHaveEnergy > DroneX.JobMap[0].isCost && DroneX.Saving.StamFirst != 1){
			setTimeout(function(){grabInfoz();},2500);
		}else if(DoesIHaveStamina < DroneX.StamMap[DroneX.StaminaSelected].isCost){
			setTimeout(function(){grabInfoz();},2500);
		}else{
			join_arena();
		}
	}
	
	function am_i_leading_by(points) {
		var i,best_player_points=0;
		for(i in currdata.pi) {
			if(i!=meid) {
				if(currdata.pi[i].sc>best_player_points) { best_player_points=currdata.pi[i].sc;}
			}
		}
		var my_score=currdata.pi[meid].sc;
		return my_score-points>best_player_points;
	}

	function are_we_leading_by(points) {
		var team1 = parseInt(tscore["1"]);
		var team2 = parseInt(tscore["2"]);
		if (meteam == 1) {
			return team1-points>team2;
		}
		else {
			return team2-points>team1;
		}
	}	
	
	// sorry, too lazy to make a generic function. If you steal this code, feel free to improve it.
	function am_i_targeting(points,targetrank) {
		var scores=[];
		for(i in currdata.pi) {
			if(i!=meid) {
				scores.push(currdata.pi[i].sc);
			}
		}
		scores.sort(function(a,b){return b-a;});
		var my_score=currdata.pi[meid].sc;
		return my_score-points>scores[targetrank-1];
	}
	
	function decide_allowed_to_attack(){
		try {
			var stopon = $('#DXspartacus_stopon').val();
			var stoponval = parseInt($('#DXspartacus_stoponvalue').val());
			var stamused = stam_on_start-currdata.mi.st;
			var score = currdata.pi[meid].sc;

			if(currdata.pi[meid].ph==0) { return false; } // me dead
			if(currdata.mi.st<10) { return false; } // no stam
			if((currdata.mi.st<50) && (poweratt)) { return false; } // no stam
			switch(stopon) {
				case "never": return true;
				case "stop": return false;
				case "teamleading": return !are_we_leading_by(stoponval);
				case "leading": return !am_i_leading_by(stoponval);
				case "leading3": return !am_i_targeting(stoponval,3);
				case "leading5": return !am_i_targeting(stoponval,5);
				case "staminaused": return stamused<stoponval;
				case "staminaleft": return currdata.mi.st>stoponval;
				case "score": return score<stoponval;
				case "stars": return currdata.ti[meteam].stars<stoponval;
			}
		} catch(err) {}
		return true;
	}
	
	function decide_who_to_attack(count){
		var i,list=[];
		// override active?
		
		if(powerup_command.target!==undefined) {
			//console.log('override');
			
			if((currdata.pi) && (currdata.pi[powerup_command.target]) && (currdata.pi[powerup_command.target].ph>0)) {
				for(i=0;i<count;i++) {
					list.push(powerup_command.target);
				}
				//console.log('override, successful:'+JSON.stringify(list));
				return list;
			} else {
				// target is not alive anymore
				powerup_command.target = undefined;
				$('.DXspartacus_kill').removeClass('DXspartacus_puactive').addClass('DXspartacus_punormal');
				// continue with normal selection
				//console.log('override not successful');
			}					
		}
		
		var target=$('#DXspartacus_seltarget').val();
		if(powerup_status.kami_active) { target="highhealth"; }
		var skipshield_d=$('#DXspartacus_skipshield').is(':checked');
		var skipshield_a=$('#DXspartacus_skipshield_a').is(':checked');
		var bestid=-1,best=0;
		for(i in currdata.pi) {
			if(i!=meid) {
				if(!protect[i]) {
					if((!meteam) || (currdata.pi[i].tm!=meteam)) { // De Morgan, attack only enemies
						if((currdata.pi[i].ph>0)) {
							if(!(
								(skipshield_d && (currdata.pi[i].pu>1)) ||
								(skipshield_a && (currdata.pi[i].pu%2==1))
							)){
								var val;
								switch(target) {
									case "lowhealth": val=100-currdata.pi[i].ph; break;
									case "highhealth": val=currdata.pi[i].ph; break;
									case "leastpoints": val=1000000-currdata.pi[i].sc; break;
									case "mostpoints": val=currdata.pi[i].sc;break;
									case "leastrespect": val=10000-playerinfo[i].respect; break;
									case "mostrespect": val=playerinfo[i].respect; break;
									case "allalive": val=1; break;
									case "leastdiff": val=3-r_difficulty[playerinfo[i].diff]; break;
								}
								if(val>best) {
									list=[];
									list.push(i);
									best=val;
								} else if(val==best) {
									list.push(i);
								}
							}
						}
					}
				}
			}
		}
		
		if(list.length==0) {
			//console.log('doh, no target.');
		} else if(list.length>count) {
			list=list.slice(0,count);
		} else if(list.length<count) {
			while(list.length<count) {
				list.push(list[0]);
			}
		}
		return list;
	}
	
	function decide_actions(){
		var numatt = parseInt($('#DXspartacus_numatt').val()) || 3;
		if(numatt>3) { numatt=3; }
		
		if(currdata.s==2) { // fight active
			if($('#DXspartacus_powerattack').is(':checked')) {
				poweratt_on();
			} else {
				poweratt_off();
			}
			// power ups
			var usekami=$('#DXspartacus_boostkami').is(':checked');
			if(usekami && !powerup_status.kami_used) {
				var kamitime = parseInt($('#DXspartacus_boostkami_s').val());
				if(currdata.t<kamitime) {
					use_powerup(5);
				}
			}
			
			// send queued powerup
			if(powerup_command.active!=-1) {
				cmdqueue.unshift('3:'+powerup_command.active);
				if ((powerup_command.active==1) || (powerup_command.active==2)) { // don't retry heal or stam refill
					powerup_command.active = -1;
					$('.DXspartacus_boost.DXspartacus_puactive').removeClass('DXspartacus_puactive').addClass('DXspartacus_punormal');
					$('.DXspartacus_boost2.DXspartacus_puactive').removeClass('DXspartacus_puactive').addClass('DXspartacus_punormal');
				}
			}

			if(decide_allowed_to_attack()) {
				var i,who=decide_who_to_attack(numatt-cmdqueue.length);
				for(i=0;i<who.length;i++) {
					attack(who[i],1);
				}
			}
			//console.log(cmdqueue);
		}
	}
	
	function parse_loot(msg){
		window.eikea=msg;
		var $msg=$('<div>'+msg+'</div>');
		var rewards={},arena={};
		var mobfury = false;
		if ($msg.find('div.team-status').length > 0) {
			mobfury = true;
			rewards.xp = parseInt($msg.find('div.xp-earned span.value').text()) || 0;
			rewards.respect = parseInt($msg.find('div.respect-earned span.value').text()) || 0;
		}
		else {
			rewards.xp = parseInt($msg.find('.xp_earned > .value').text()) || 0;
			rewards.respect = parseInt($msg.find('.respect_earned > .value:first').text()) || 0;
		}
		//rewards.xp = (mobfury ? parseInt($msg.find('span.value:first','div.xp-earned').text()) : parseInt($msg.find('.xp_earned > .value').text()));
		//rewards.respect = (mobfury ? parseInt($msg.find('span.value:first','div.respect-earned').text()) : parseInt($msg.find('.respect_earned > .value:first').text()));
		if($msg.find('.respect_earned > .label:last').text().indexOf('Crests')!=-1) {
			rewards.crests=parseInt($msg.find('.respect_earned > .value:last').text()) || 0;
		}
		rewards.stam_cur=parseInt($msg.find('.stamina_stats > .current').text());
		rewards.stam_total=parseInt($msg.find('.stamina_stats > span:last').text());
		if (mobfury) {
			if($msg.find('div.team-board.winner').find('li.myself').length > 0) {
				rewards.rank = 1;
			}
			else {
				rewards.rank = 6;
			}
			// get my team, there is probably an easier way for that
			if($msg.find('.team-red .myself').length>0) {
				rewards.stars=$msg.find('.team-red .gold-star').length;
			} else {
				rewards.stars=$msg.find('.team-blue .gold-star').length;
			}
		}
		else {
			rewards.rank = $msg.find('.rank_holder > .position').text();
		}
		if(currdata) {
			rewards.stamused=(stam_on_start - currdata.mi.st);
			rewards.currst = currdata.mi.st;
		}
		rewards.ratio=(rewards.xp / rewards.stamused).toFixed(2);
		rewards.loot=[];
		rewards.points=parseInt($('#DXspartacus_score'+meid).text());
		
		var loot_strings=[];
		$($msg.find('#your_reward_list > .arena_fight_rewards_item_container')).each(function(){
			var loot = {};
			loot.name = $(this).find('.arena_reward_items_bg > .name').text().trim() || $(this).find('.arena_reward_items_special_bg > .name').text().trim();
			loot.id = $(this).find('.arena_reward_items_bg img').attr('item_id') || false;
			loot.src = $(this).find('.arena_reward_items_bg img').attr('src') || $(this).find('.arena_reward_items_special_bg img').attr('src');
			loot.quantity = parseInt($(this).find('.qty').text().trim().substr(2)) || 1;
			loot.attack = parseInt($(this).find('.attack').text().trim()) || 0;
			loot.defense = parseInt($(this).find('.defense').text().trim()) || 0;
			rewards.loot.push(loot);
			loot_strings.push('<img src="'+loot.src+'" class="item_with_preview" item_id="'+loot.id+'" width="16" height="16">'+loot.name+' <span class="good">&times;'+loot.quantity+'</span> ');
			add_loot(loot);
		});
		if(rewards.crests){
			var loot={ name:"Crests", src:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/crestlogo_16.png",quantity:rewards.crests };
			rewards.loot.push(loot);
			loot_strings.unshift('<img src="'+loot.src+'" class="item_with_preview" item_id="'+loot.id+'" width="16" height="16">'+loot.name+' <span class="good">&times;'+loot.quantity+'</span> ');
			add_loot(loot);
		}
		if(rewards.stars) {
			var loot={ name:"Stars", src:"https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/Arena/TeamVSTeam/result_star_filled.png",quantity:rewards.stars };
			rewards.loot.push(loot);
			loot_strings.unshift('<img src="'+loot.src+'" width="16" height="16">'+loot.name+' <span class="good">&times;'+loot.quantity+'</span> ');
			add_loot(loot);
		}
		// console.log(rewards);
		log('Result: #'+rewards.rank+' <span class="experience">'+rewards.xp+' ('+rewards.ratio+')</span> <span class="respect">'+(rewards.respect>0?'+':'')+rewards.respect+'</span> '+loot_strings.join(''));
		write_loot();
		update_crests();
		
		var logline='';
		var opponents=0, opponentname='',name='',score=0,resp=0,pos=1;
		if (mobfury) {
			//Team Red
			logline += '[<span '+$c('teamred')+'"><strong>Team Red</strong></span>] ';
			$($msg.find('div.team-red .standings_list')).each(function(){
				name = $(this).find('.name').text();
				score = $(this).find('.score').text();
				resp = $(this).find('.respect_wrapper').html();
				logline += pos+'. '+name+' <span class="respect">'+resp+'</span> Score: '+score+' - ';
				pos++;
			});
			//Team Blue
			logline += ' [<span '+$c('teamblue')+'"><strong>Team Blue</strong></span>] ';
			pos = 1;
			$($msg.find('div.team-blue .standings_list')).each(function(){
				name = $(this).find('.name').text();
				score = $(this).find('.score').text();
				resp = $(this).find('.respect_wrapper').html();
				logline += pos+'. '+name+' <span class="respect">'+resp+'</span> Score: '+score+' - ';
				pos++;
			});
			arena.teamred = parseInt($msg.find('#team-red-score').text()) || 0;
			arena.teamblue = parseInt($msg.find('#team-blue-score').text()) || 0;
			arena.type = 'mobfury';
			opponentname = 'Mob Fury';
			stats.respect = parseInt($msg.find('li.standings_list.myself div.respect_wrapper').html());
		}
		else {
			$($msg.find('.standings_list')).each(function(){
				var pos=$(this).find('.pos').text();
				var name=$(this).find('.name').text();
				var resp=$(this).find('.respect_wrapper').html();
				var powerups='';
				$(this).find('.powerups_used img').each(function(){
					powerups+='<img src="'+this.src+'" width="16" height="16" />';
				});
				logline+=pos+'. '+name+' <span class="respect">'+resp+'</span> '+powerups+' ';
				if(pos==parseInt(rewards.rank)) { stats.respect=parseInt(resp); }
				opponents++;
				if(!$(this).hasClass('its_me') || !$(this).hasClass('myself')) { opponentname=name; }
			});
		}
		log(logline);
		
		// arena list
		arena.rank = parseInt(rewards.rank);
		arena.stam = rewards.stamused>0?rewards.stamused:0;
		arena.points = rewards.points;
		arena.crests = rewards.crests;
		arena.opponents = (mobfury ? 1 : opponents);
		arena.opponentname = opponentname;
		arena.diff = '';
		arena.currst = rewards.currst;
		$('span[id*="spartacus_diff"]').each(function(){arena.diff+=$(this).text().substr(0,1);})		
		arenalist.push(arena);
		write_arenas();

		if(msg.indexOf('You are now LEVEL')!=-1) {
			log('<span class="good">Levelup!</span>');
			grab_bonus();
		}
		stats.stamina+=rewards.stamused;
		stats.xp+=rewards.xp;
		stats.arenas++;
		if(rewards.stars) {
			stats.stars+=rewards.stars;
		}
		stats.ranks[parseInt(rewards.rank)-1]++;
		stats.crests+=rewards.crests;
		stats.score+=rewards.points;
	}
	
	function add_loot(item) {
		var id = (Util.isset(item.id) ? item.id : item.name);
		if (typeof looted[id] == 'object') {
			looted[id].quantity += item.quantity;
		}
		else {
			looted[id] = {
				"id": id, "name": item.name, "src": item.src, "quantity": item.quantity, "attack":item.attack, "defense":item.defense
			}
		}
	}

	function sort_loot(){
		var x,list = [];
		for (x in looted) {
			list.push(x);
		}
		list.sort(function(a,b){
			if(looted[a].name=="Ices") { return -1; }
			if(looted[b].name=="Ices") { return 1; }
			if(looted[a].name=="Crests") { return -1; }
			if(looted[b].name=="Crests") { return 1; }
			if(looted[a].name=="Stars") { return -1; }
			if(looted[b].name=="Stars") { return 1; }
			return compare(max(looted[a].attack,looted[a].defense),max(looted[b].attack,looted[b].defense));
		});
		return list;
	}
	
	function write_loot() {
		var sorted=sort_loot();
		var loothtml = '<table>';
		for (i=0;i<sorted.length;i++) {
			var loot = looted[sorted[i]];
			var image = '<img src="'+loot.src+'" class="item_with_preview" item_id="'+loot.id+'" title="'+loot.name+'" width="16" height="16" />';
			if (itemdatabase[loot.id]) {
				var loot2 = itemdatabase[loot.id];
				var attack = '', defense = '', improves = false, improve = '', stopat = '';
				if (loot2.attack > 0) {
					attack = '['+loot2.attack+'A';
					if(worstitems[itemdatabase[loot.id].type].att<loot2.attack) {
						improves = true;
						improve += '<span class="attack good">+'+(loot2.attack - worstitems[itemdatabase[loot.id].type].att)+'</span> ';
					}
				}
				if (loot2.defense > 0) {
					defense = loot2.defense+'D]';
					if(worstitems[itemdatabase[loot.id].type].def<loot2.defense) {
						improves = true;
						improve += '<span class="defense good">+'+(loot2.defense - worstitems[itemdatabase[loot.id].type].def)+'</span>';
					}
				}
				var have = loot.quantity;

				have = (loot2.quantity>0?' <span class="more_in">Have: '+(loot2.quantity+loot.quantity)+'</span>':'');
				loothtml += '<tr><td><span class="good">&times;'+loot.quantity+'</span></td><td>'+image+'<span style="'+(improves?"color:yellow;":"")+'">'+loot2.name+'</td><td>'+attack+'</td><td>'+defense+'</span></td><td>'+improve+'</td><td>'+have+'</td></tr>';
			}
			else
			{
				if(loot.name=="Ices") {
					loothtml += '<tr><td><span class="good">&times;'+loot.quantity+'</span></td></td><td><span style="color: #609AD1; font-weight:bold;">'+image+loot.name+'</span></td><td></tr>';
				} else if (loot.name=="Stars") {
					loothtml += '<tr><td><span class="good">&times;'+loot.quantity+'</span></td></td><td><span style="color: yellow; font-weight:bold;">'+image+loot.name+'</span></td><td></tr>';
				} else {
					loothtml += '<tr><td><span class="good">&times;'+loot.quantity+'</span></td></td><td>'+image+loot.name+'</td><td></tr>';
				}
			}
		}
		loothtml += '</table>';
		$('#DXspartacus_lootlog').html(loothtml);
	}
	
	function get_stage(i) {
		if(i==0) { return "Waiting for more players.."; }
		if(i==1) { return "Waiting for Start."; }
		if(i==2) { return "Fighting!"; }
		if(i==3 && ARS) { return "Drone Stopped"; }
		else if(i==3 && !ARS) { return "Finished."; }
		return "Unknown:"+i;
	}

	function send_queue() {
		if(cmdqueue.length>0) {
			var string='{"Nonce":'+currdata.mi.ammo+',"CMD":"'+cmdqueue.join(';')+'"}'
			cmdqueue=[];
			socke.send(string);
		}
	} 

	function attack(i,num) {
		var j;
		for(j=0;j<num;j++) {
			cmdqueue.push("1:"+i);
		}
	}

	function poweratt_on() {
		if(poweratt!==true) {
			cmdqueue.push("2:1");
			poweratt=true;
		}
	}

	function poweratt_off() {
		if(poweratt!==false) {
			cmdqueue.push("2:0");
			poweratt=false;
		}
		return false
	}


	function use_powerup(id) {
		powerup_command.active=id;
		powerup_command.target=undefined;
	}	

	function loadInventoryAAN() {
		User.clicks++;
		var zserver = /\/\/(.*)\.mafiawars/.exec(document.location.href)[1];
		var preurl = '//'+zserver+'.mafiawars.zynga.com/mwfb/remote/html_server.php?';
		var params = {
			'ajax': 1,
			'xw_client_id': 8,
			'liteload': 1,
			'sf_xw_user_id': User.id,
			'sf_xw_sig': local_xw_sig,
			'xw_city': 1,
			'clicks': User.clicks
		};
		$.ajax({
			type: "POST",
			url: preurl+'xw_controller=inventory&xw_action=view&from_controller=inventory',
			data: params,
			cache: false,
			success: function(response){
				//itemdatabase = {};
				var ZyngaItems = jQuery.parseJSON(/var Items = \{\s+data: (\{.*?\})\};/.exec(response)[1]);
				worstitems = jQuery.parseJSON(/MW.WorstItemsModule.update\((\{.*\})\);/.exec(response)[1]);
				//Locations = jQuery.parseJSON(/var Locations = \{\s+data: (\{.*?\})\};/.exec(response)[1]);
				for (x in ZyngaItems) {
					ZyngaItems[x].combined = parseInt(ZyngaItems[x].attack+ZyngaItems[x].defense);
					itemdatabase[ZyngaItems[x].id] = ZyngaItems[x]; //{quantity: ZyngaItems[x].quantity}
				}
				log('Inventory load complete.');
			},
			error: function(){
				log('<span class="bad">Inventory Load failed!</span>');
			}
		});
	}
	
	function getStats(handler) {
		AjxRequest('xw_controller=propertyV2&xw_action=createData&xw_city=7&tmp=&cb=&xw_person='+User.id.substr(2)+'&mwcom=&city=7&xw_client_id=8',function(msg){
			var data = JSON.parse(msg);
			update_game_ui_sp(data);
			stats.mafiaatt=parseInt(data.fightbar.group_atk);
			stats.mafiadef=parseInt(data.fightbar.group_def);
			stats.stam=parseInt(data.user_fields.user_max_stamina);
			stats.worstitems=data.worstitems;
			if(handler) { handler(); }
		});
	}
	
	function sdiff(num,color) {
		if(num==0) {
			return '&plusmn;0';
		} else if(num>0) {
			return '+'+num;
		} else {
			return num;
		}
	}
	function cmp(v1,v2){
		return (v1>v2?-1:(v1<v2?1:0));
	}
	
	var Ping = {
		inUse:false,
		start:0,
		ping:function(ip, callback) {
			if(!this.inUse) {

				this.inUse = true;
				this.callback = callback
				this.ip = ip;

				var _that = this;

				this.img = new Image();

				this.img.onload = function() {_that.good();};
				this.img.onerror = function() {_that.good();};

				this.start = (new Date()).getTime();
				this.img.src = "http://" + ip + '?id='+Math.random(4);
				this.timer = setTimeout(function() { _that.bad();}, 1500);
			}
		},
		good:function(){
			if(this.inUse) {
				this.inUse = false;
				this.callback((new Date()).getTime()-this.start);
				clearTimeout(this.timer);
			}
		},
		bad:function(){
			if(this.inUse) {
				this.inUse = false;
				this.callback(-1);
			}
		}
	}
	
	function update_game_ui_sp(object) {
		if (Util.isset(object.user_fields)) {
			user_fields_update(object.user_fields);
			user_info_update(object.user_fields, object.user_info);
			if (Util.isset(object.user_fields.zmc_event_count)) {
				$('#zmc_event_count').text(object.user_fields.zmc_event_count);
			}
		}
		if (Util.isset(object.questData)) {
			MW.QuestBar.update(object.questData);
		}
	}	
	
	function loadStats(){
		getStats(function(){
			// save first stats
			stats.start_mafiaatt=stats.mafiaatt;
			stats.start_mafiadef=stats.mafiadef;
			loadInventoryAAN();
		});
	}
	loadStats(); // mafia att, def and inventory
	function isArray(obj) {
		return obj.constructor == Array;
	}
	
	function displayMafiaStats(){
		$('#DXspartacus_strength_stats').html('');
		$('#DXspartacus_strength_stats').append(mafia_attack+' '+commas(stats.mafiaatt)+' (<span class="'+(stats.mafiaatt-stats.start_mafiaatt >= 0?'good">+':'bad">')+''+commas(stats.mafiaatt-stats.start_mafiaatt)+'</span>) ');
		$('#DXspartacus_strength_stats').append(mafia_defense+' '+commas(stats.mafiadef)+' (<span class="'+(stats.mafiadef-stats.start_mafiadef >= 0?'good">+':'bad">')+''+commas(stats.mafiadef-stats.start_mafiadef)+'</span>) ');
		setTimeout(function(){ delayArenaChk(); },1000);	
		display_all_stats();
	}
	
	function display_all_stats(){
		var html='';
		html+='Total arenas: '+stats.arenas+' ';
		html+='[';
		html+=stats.ranks[0]+'&times1st, ';
		html+=stats.ranks[1]+'&times2nd, ';
		html+=stats.ranks[2]+'&times3rd, ';
		html+=stats.ranks[3]+'&times4th, ';
		html+=stats.ranks[4]+'&times5th, ';
		html+=stats.ranks[5]+'&times6th';
		html+=']<br />';

		html+='Respect: <span class="respect">'+stats.respect+' ('+sdiff(stats.respect - stats.respect_start)+')</span> ';
		if(stats.crests) {
			html+='Crests: <span class="arena_mastery_crests">'+sdiff(stats.crests)+'</span> ';
		}
		html+='<span class="experience" title="XP earned">'+stats.xp+'</span> ';
		html+='<span class="attack" title="Score/Damage done">'+stats.score+'</span> ';
		html+='<span class="stamina" title="Stamina spent">'+stats.stamina+'</span> ';
		html+='<span class="experience" title="XP/Stamina">'+(stats.stamina==0?0:(stats.xp/stats.stamina).toFixed(2))+'</span> ';
		html+='<span class="attack" title="Damage/Stamina">'+(stats.stamina==0?0:(stats.score/stats.stamina).toFixed(2))+'</span> ';
		if(stats.stars) {
			html+='<span class="good">'+starimg+stats.stars+'</span> '
		}

		$('#DXspartacus_allstats').html(html);
	}

	function min(a,b){
		return a<b?a:b;
	}
	function max(a,b){
		return a>b?a:b;
	}
	function imgurl(img,w,h,a) {
		return '<img src="http://mwfb.static.zgncdn.com/mwfb/graphics/'+img+'" width="'+w+'" height="'+h+'" title="'+a+'" alt="'+a+'" align="absmiddle">';
	}
	function commas(s) {
		var d;
		while (d=/(-)?(\d+)(\d{3}.*)/.exec(s)) {
			s = (d[1]?d[1]+d[2]+','+d[3]:d[2]+','+d[3]);
		}
		return s;
	}
	function unix_timestamp() {
		return parseInt(new Date().getTime().toString().substring(0, 10));
	}
	function compare(a,b) {
		if (a==b) { return 0; }
		if (a>b) { return -1; }
		return 1;
	}

	function timestamp(sec) {
		var now = new Date();
		var CurH = now.getHours();
		CurH = (CurH<10?'0'+CurH:CurH);
		var CurM = now.getMinutes();
		CurM = (CurM<10?'0'+CurM:CurM);
		var CurS = now.getSeconds();
		CurS = (CurS<10?'0'+CurS:CurS);
		if(sec) {
			return '<span class="more_in">['+CurH+':'+CurM+':'+CurS+']</span> ';
		} else {
			return '<span class="more_in">['+CurH+':'+CurM+']</span> ';
		}
	}

/*	function log(message){
		message='<span class="more_in">'+timestamp()+'</span> '+message;
		logs.unshift(message);
	} */
	
	function update_info(data) {
		if(data.s==2) {
			// update last data received
			if(last_update>0) {
				var newtime=(new Date()).getTime();
				$('#DXspartacus_delay').text((newtime-last_update)+'ms');
				last_update=newtime;
				window.eike=update_debug;
			} else {
				last_update=(new Date()).getTime();
			}
		}

		set_progress_bar(data.t,data.s==2?90:20,data.t+' seconds left');

		// counter
		if(data.s==1) {
			starting_in = unix_timestamp()+data.t;
			clearInterval(starting_in_counter) ;
			starting_in_counter = setInterval(function(){
				if(starting_in < unix_timestamp()) {
					clearInterval(starting_in_counter) ;
				} else {
					set_progress_bar(parseInt(starting_in - unix_timestamp()),20,starting_in - unix_timestamp()+' seconds left');
				}
			},1000);
			if(data.mi) {
				stam_on_start = data.mi.st; // save at start
			}
		}
		else {
			clearInterval(starting_in_counter);
		}


		if(data.mi && (stam_on_start==-1)) {
			stam_on_start = data.mi.st;
		}

		$('#DXspartacus_stage').html(get_stage(data.s));
		if(data.s<1) {
			$('#DXspartacus_stage').append(' <a href="#" id="DXspartacus_leave">(leave)</a>');
			$('#DXspartacus_leave').click(function(){
				socke.send('{"Nonce":-1,"CMD":"2"}');
				return false;
			});
		}

		tscore={"1":0,"2":0};
		
		// enemy powerups
		for(i in data.pi) {
			var pi=data.pi[i];
			// thanks Alex for this idea
			if(pi.ph == 0){
				if(healtimer[i]<10) {
					healtimer[i] = unix_timestamp() + 10;
					$('#DXspartacus_usepu'+i+' > .DXspartacus_boost').removeClass('DXspartacus_puclick').addClass('DXspartacus_punoclick').removeClass('DXspartacus_pufull').addClass('DXspartacus_puoff');
					$('#DXspartacus_usepu'+i+' > .DXspartacus_kill').removeClass('DXspartacus_puclick').addClass('DXspartacus_punoclick').removeClass('DXspartacus_pufull').addClass('DXspartacus_puoff');
					$('#DXspartacus_usepu'+i+' > .DXspartacus_boost2').removeClass('DXspartacus_punoclick').addClass('DXspartacus_puclick').removeClass('DXspartacus_puoff').addClass('DXspartacus_pufull');
				}
				var t=(healtimer[i] - unix_timestamp()); if(t<1) { t=1; }
				$('#DXspartacus_health'+i).html('<span class="bad">in '+t+'s</span>');
			}
			else {
				$('#DXspartacus_health'+i).html(pi.ph.toFixed(1)+'%');
					$('#DXspartacus_usepu'+i+' > .DXspartacus_boost').removeClass('DXspartacus_punoclick').addClass('DXspartacus_puclick').removeClass('DXspartacus_puoff').addClass('DXspartacus_pufull');
					$('#DXspartacus_usepu'+i+' > .DXspartacus_kill').removeClass('DXspartacus_punoclick').addClass('DXspartacus_puclick').removeClass('DXspartacus_puoff').addClass('DXspartacus_pufull');
					$('#DXspartacus_usepu'+i+' > .DXspartacus_boost2').removeClass('DXspartacus_puclick').addClass('DXspartacus_punoclick').removeClass('DXspartacus_pufull').addClass('DXspartacus_puoff');
			}
			if(unix_timestamp()>healtimer[i]) {
				healtimer[i] = 0;
			}

			$('#DXspartacus_score'+i).html(pi.sc);
			//team colors
			if (pi.tm == 1) {
				$('#DXspartacus_op'+i).addClass('DXspartacus_teamred');
			}
			else if (pi.tm == 2) {
				$('#DXspartacus_op'+i).addClass('DXspartacus_teamblue');
			}
			else {
				$('#DXspartacus_op'+i).removeClass('DXspartacus_teamblue').removeClass('DXspartacus_teamred');
			}
			// team score
			if(pi.tm) {
				tscore[pi.tm]+=pi.sc;
			}
			
			var puhtml='';
			if(pi.pu>1) { puhtml+='<span class="DXspartacus_defsh">&nbsp;</span> '; }
			if(pi.pu%2==1) { puhtml+='<span class="DXspartacus_offsh">&nbsp;</span> '; }
			$('#DXspartacus_pu'+i).html(puhtml);
		}
		// update teamscore
		if(data.ti) {
			if(data.ti["1"] && data.ti["2"]) {
				tscore["1"]+=2000 * data.ti["1"].stars;
				tscore["2"]+=2000 * data.ti["2"].stars;
				var t1=tscore["1"], t2=tscore["2"];
				var s1='',s2='';
				if(data.ti["1"].stars==0) {
					s1=nostarimg;
				} else {
					for(var i=0;i<data.ti["1"].stars;i++) { s1+=starimg; }
				}
				if(data.ti["2"].stars==0) {
					s2=nostarimg;
				} else {
					for(var i=0;i<data.ti["2"].stars;i++) { s2+=starimg; }
				}

				if(meteam==1) {
					$('#DXspartacus_teamscore').html('<span style="color:#ec2d2d;">Team Red (you)</span> score: <span class="'+(t1>=t2?'good':'bad')+'">'+t1+'</span> '+s1+' vs. <span style="color:#0099FF;">Team Blue</span> score: <span class="'+(t2>=t1?'good':'bad')+'">'+t2+'</span> '+s1);
				} else {
					$('#DXspartacus_teamscore').html('<span style="color:#0099FF;">Team Blue (you)</span> score: <span class="'+(t2>=t1?'good':'bad')+'">'+t2+'</span> '+s2+' vs. <span style="color:#ec2d2d;">Team Red</span> score: <span class="'+(t1>=t2?'good':'bad')+'">'+t1+'</span> '+s1);
				}
			}
		}
		if(data.mi) {
			$('#DXspartacus_me_st').html(data.mi.st);
			//$('#DXspartacus_me_ammo').html(data.mi.ammo);
//			$('#DXspartacus_me_pst').html(data.mi.pst);
			if(data.mi.pui) {
				update_powerups(data.mi.pui);
			}
			$('#DXspartacus_me_sr').html(data.mi.sr);

			if(currdata && currdata.mi) {
				if(data.mi.st>currdata.mi.stam+100) { // used used a stam refill
					log('Used a stamina refill!');
					stam_on_start += (data.mi.st-currdata.mi.stam);
				}
			}
			$('#DXspartacus_me_stused').html(stam_on_start - data.mi.st);
			if (Util.isset(data.mi.tpst)) {
				var stamarr = data.mi.tpst.split('|'), stai;
				for (stai=0;stai<stamarr.length;stai++) {
					var stampi = stamarr[stai].split(',');
					$('#DXspartacus_stam'+stampi[0]).html(stampi[1]+'%');
				}
			}
		}

		// healing timer
		if(meid) {
			$('#DXspartacus_me_health').removeClass('good').removeClass('bad').addClass(data.pi[meid].ph>0?'good':'bad').html(data.pi[meid].ph);
			if((data.pi[meid].ph==0) && (currdata.pi[meid].ph>0)) {
				healed_in=unix_timestamp()+10;
				clearInterval(healed_in_counter);
				healed_in_counter = setInterval(function(){
					if(unix_timestamp()>healed_in) {
						clearInterval(healed_in_counter);
						$('#DXspartacus_healin').html('');
					} else {
						$('#DXspartacus_healin').html('Healing in '+(healed_in - unix_timestamp())+'s');
					}
				},1000);
			} else {
				try {
					$('#DXspartacus_healin').html('');
					clearInterval(healed_in_counter);
				} catch(e){ }
			}
		}

		for(i in data.pi) {
			if((data.pi[i].pid) && (!playerids[data.pi[i].pid])) {
				playerinfo[i]={ id:data.pi[i].pid };
				playerids[data.pi[i].pid]=i;
				if(data.pi[i].pid==User.id.substr(2)) {
					meid=i;
				}

				AjxRequest('xw_controller=Arena&xw_action=getSingleUserData&pid='+data.pi[i].pid+'&xw_client_id=8',function(msg){
					var id,json=JSON.parse(msg);
					for(id in json.data.result) {
						var nr=playerids[id];
						playerinfo[nr].name=json.data.result[id].name;
						playerinfo[nr].respect=json.data.result[id].playerRespect.replace(',','').replace('K','000');
						playerinfo[nr].diff=difficulty[json.data.result[id].defenseFlag+json.data.result[id].mafiaDefenseFlag];
						if(id == User.id.substr(2)) {
							$('#DXspartacus_name'+nr).html('<span id="DXspartacus_hover'+nr+'"><img src="'+json.data.result[id].pic+'" width="32" height="32" /><span class="good">Me!</span></span>');
							$('#DXspartacus_diff'+nr).html('<div class="difficulty">-</div>');
							if(!stats.respect) { stats.respect_start=json.data.result[id].playerRespect.replace(',','').replace('K','000'); }
							$('#DXspartacus_usepu'+nr).html(
								'<img src="'+powerups[2].pic+'" width="24" height="24" data-id="2" '+$c('boost2',['puoff','punoclick','punormal'])+' title="Use health boost">'+
								'<img src="'+powerups[3].pic+'" width="24" height="24" data-id="3" '+$c('boost',['pufull','puclick','punormal'])+' title="Use meta flair">'+
								'<img src="'+powerups[4].pic+'" width="24" height="24" data-id="4" '+$c('boost',['pufull','puclick','punormal'])+' title="Use pain killer">'+
								'<img src="'+powerups[7].pic+'" width="24" height="24" data-id="7" '+$c('boost',['pufull','puclick','punormal'])+' title="Use reflector">'
							);
						}
						else {
							var m;
							$('#DXspartacus_name'+nr).html('<span id="DXspartacus_hover'+nr+'"><img src="'+json.data.result[id].pic+'" width="32" height="32" />'+playerinfo[nr].name+'</span>');
							$('#DXspartacus_name'+nr).append('<span data-id="'+id+'" id="DXspartacus_infobox'+nr+'" style="display:none;position:absolute;border:2px white solid;background-color:#222;padding:5px;border-radius:5px;">loading...</span>');
							$('#DXspartacus_diff'+nr).html('<div class="difficulty">'+playerinfo[nr].diff+'</div>');
							var target='https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/leaderboard/leaderboardTarget.png';
							var defense='https://zynga1-a.akamaihd.net/mwfb/mwfb/graphics/icon-defense_04.gif';
							$('#DXspartacus_usepu'+nr).html(
								'<img src="'+powerups[5].pic+'" width="24" height="24" data-nr="'+nr+'" data-id="5" '+$c('boost',['pufull','puclick','punormal'])+' title="Nuke opponent (Kamikaze)">'+
								'<img src="'+powerups[6].pic+'" width="24" height="24" data-nr="'+nr+'" data-id="6" '+$c('boost',['pufull','puclick','punormal'])+' title="Use drain on opponent">'+
								'<img src="'+target+'" width="24" height="24" data-nr="'+nr+'" '+$c('kill',['pufull','puclick','punormal'])+' title="Hit this player until dead" >'+
								'<img src="'+defense+'" width="24" height="24" data-nr="'+nr+'" '+$c('protect',['puhalf','puclick','punormal'])+' title="Do not attack this player (click to enable, click again to disable)" >'


							);
						}
						$('#DXspartacus_name'+nr).append('<span data-id="'+id+'" id="DXspartacus_infobox'+nr+'" style="display:none;position:absolute;border:2px white solid;background-color:#222;padding:5px;border-radius:5px;">loading...</span>');

						$('#DXspartacus_respect'+nr).html(playerinfo[nr].respect);
						var testnumbs = 'dxspartacus';
						$('#DXspartacus_hover'+nr).hover(function(event){
							var num=this.id.substr(6+testnumbs.length);
							var id=$('#DXspartacus_infobox'+num).attr('data-id');
							$('#DXspartacus_infobox'+num).css("top",event.pageY+'px').css("left",(event.pageX-100)+'px');
							if(!$('#DXspartacus_infobox'+num).attr('spdone')) {
								$('#DXspartacus_infobox'+num).html('Profile loading...');
								load_player_profile(id,num);
							}
							$('#DXspartacus_infobox'+num).show();
						},function(){
							var num=this.id.substr(6+testnumbs.length);
							$('#DXspartacus_infobox'+num).hide();
						});
						
						
						/* intervene, protect */
						$('#DXspartacus_usepu'+nr,' > .DXspartacus_protect').click(function(){
							var pnr=$(this).attr('data-nr');
							if(protect[pnr]) {
								delete protect[pnr];
								$(this).removeClass('DXspartacus_pufull').addClass('DXspartacus_puhalf');
							} else {
								protect[pnr] = 1;
								$(this).removeClass('DXspartacus_puhalf').addClass('DXspartacus_pufull');
							}
						});
						
						/* intervene, kill */
						$('#DXspartacus_usepu'+nr,' > .DXspartacus_kill').click(function(){
							if($(this).hasClass('DXspartacus_puclick')) { // only when active
								var pnr=$(this).attr('data-nr');
								if(powerup_command.target==pnr) { // turn off
									$(this).removeClass('DXspartacus_puactive').addClass('DXspartacus_punormal');
									powerup_command.target=undefined;
								} else if (powerup_command.target===undefined) { // no target yet
									$(this).removeClass('DXspartacus_punormal').addClass('DXspartacus_puactive');
									powerup_command.target=pnr;
								} else { // switch target
									$('#DXspartacus_usepu'+powerup_command.target,' > img.DXspartacus_kill').removeClass('DXspartacus_puactive').addClass('DXspartacus_punormal');
									$(this).removeClass('DXspartacus_punormal').addClass('DXspartacus_puactive');
									powerup_command.target=pnr;
								}
							}
						});
						
						/* intervene, boost */
						$('#DXspartacus_usepu'+nr+' > .DXspartacus_boost,#DXspartacus_usepu'+nr+' > .DXspartacus_boost2').click(function(){
							//console.log('click');
							if($(this).hasClass('DXspartacus_puclick')) { // only when active
								var puid=$(this).attr('data-id');
								var pnr=$(this).attr('data-nr');
								$('.DXspartacus_boost.DXspartacus_puactive').removeClass('DXspartacus_puactive').addClass('DXspartacus_punormal');
								$(this).removeClass('DXspartacus_punormal').addClass('DXspartacus_puactive');
								powerup_command.active = puid;
								powerup_command.target = pnr;
							}
						});
					}
				});
			}

			if(!meteam) {
				if(data.pi[i] && (data.pi[i].pid==User.id.substr(2))) {
					if(data.pi[i].tm!=0) {
						meteam=data.pi[i].tm;
						//log('found team:'+meteam);
					}
				}			
			}
		}
		// sort player and rank
		var rank=[];
		for(i in playerinfo) {
			rank.push(i);
		}
		try {
			rank.sort(function(a,b){return cmp(data.pi[a].sc, data.pi[b].sc);});
		} catch (notyetstartederror) {}
		for(i=0;i<rank.length;i++){
			if(!$('#DXspartacus_sortplayer').is(':checked')) {
				if(!over_table) {
					$('#DXspartacus_table').append($('#DXspartacus_op'+rank[i]));
				}
			}
			$('#DXspartacus_rank'+rank[i]).html('#'+(i+1));
		}
		// save old
		currdata=data;
	}
	
	function load_player_profile(id,nr) {
		$('#DXspartacus_infobox'+nr).attr('spdone','true');
		AjxRequest('xw_controller=stats&xw_action=view&user='+btoa('p|'+id),function(result){
			var $msg=$('<div>'+result.replace(/<img/g,'<noimg')+'</div>');
			window.eike1=result;
			window.eike2=$msg;
			try {
				var name=$msg.find('.stats_title_text').html().re('a> ([^>]*)"');
				var level=$msg.find('.stats_title_text').html().re('level (\\d*)');
				var tag=$msg.find('.stats_title_text > a').text().trim();
				var llink=$msg.find('.stats_title_text > a').attr('href');
				var arena_stats=$msg.find('#arena_collection .collection_list').text().trim().replace(/s*\n\s*/g,"<br />").replace(/:/g,': ');
				var mafia=$msg.find('a:contains("Ask Mafia to Attack")').length==0;
				var fid=atob(unescape(llink.re('id=([^&]*)&')));
			} catch(nofam) {
				var name=$msg.find('.stats_title_text').text().trim().re('"(.*)"');
				var tag="no family";
				var llink='';
			}
			var html='Full name: '+name+'<br />'+
			'Family: '+tag+' ('+fid+')<br/>'+
			'Level: '+level+'<br />'+
			(mafia?'<span class="good">In your mafia</span>':"Not a mafia member")+'<br /><br />'+
			arena_stats;
			$('#DXspartacus_infobox'+nr).html(html);
			if(tag&&llink) {
				var zserver = /\/\/(.*)\.mafiawars/.exec(document.location.href)[1];
				$('#DXspartacus_hover'+nr+' > img').after(
					'<a href="http://'+zserver+'.mafiawars.zynga.com/mwfb/remote/html_server.php?xw_controller=clan&xw_action=view&xw_city=7&mwcom=1&id='+escape(btoa(fid))+'&from_red_link=1" class="mw_new_ajax" selector="#inner_page"><span style="color:red">'+tag+'</span></a> '
				);
			}
		});
	}

	function $c(element,spockclasses,otherclasses) {
		var i,str=' class="DXspartacus_'+element+'';
		if($.isArray(spockclasses)) {
			for(i=0;i<spockclasses.length;i++) {
				str+=' DXspartacus_'+spockclasses[i];
			}
		}
		if($.isArray(otherclasses)) {
			for(i=0;i<otherclasses.length;i++) {
				str+=' '+otherclasses;
			}
		}
		str+='"';
		return str;
	}

	// by Eike
	String.prototype.re = function(regex){
		var r=new RegExp(regex);
		var m;
		if(m=r.exec(this)) {
			return m[1];
		} else {
			return '';
		}
	}

	function update_powerups(pui) {
		var html='<table><tr>';
		var i,pups=pui.split('|');
		for(i=0;i<pups.length;i++) {
			var pup=pups[i].split(',');
			var m=(pup[0].indexOf('-')===0);
			pup[0]=Math.abs(pup[0]);
			poweruplist[pup[0]]={ num:pup[2],cooldown:pup[1],type:m }
			if((powerup_command.count[pup[0]]!=pup[2]) && (powerup_command.active==pup[0])) {
				powerup_command.active=-1;
				$('.DXspartacus_boost.DXspartacus_puactive').removeClass('DXspartacus_puactive').addClass('DXspartacus_punormal');
			}
			powerup_command.count[pup[0]]=pup[2];
		}
		for(i in powerups) {
			if((poweruplist[i].cooldown>0) && (i!=5)) {
				html+='<td valign=top style="text-align:center;"><img class="DXspartacus_notusepowerup" data-id="'+i+'" src="'+powerups[i].pic+'" title="'+powerups[i].name+'" width="60" height="60" /><br />&times'+poweruplist[i].num;
				html+='<br /><span title="On cooldown or active">A/C</span> '+poweruplist[i].cooldown+'s</span>';
			} else if (powerup_command.active==i) {
				html+='<td valign=top style="text-align:center;"><img class="DXspartacus_notusepowerup" data-id="'+i+'" src="'+powerups[i].pic+'" title="'+powerups[i].name+'" width="60" height="60" /><br />&times'+poweruplist[i].num+
				'<br /><span title="Firing (sending command to server)">Fire</span>';
			} else {
				html+='<td valign=top style="text-align:center;"><img class="DXspartacus_usepowerup" data-id="'+i+'" src="'+powerups[i].pic+'" title="'+powerups[i].name+'" width="60" height="60" /><br />&times'+poweruplist[i].num;
				html+='<br /><span id="DXspartacus_pustatus'+i+'"></span>';
			}
			html+='</td>';
		}
		html+='</table>';
		if(poweruplist[5].cooldown>0) {
			powerup_status.kami_active = true;
			powerup_status.kami_used = true;
		}


		$('#DXspartacus_powerups').html(html);
		$('.DXspartacus_usepowerup').click(function(){
			var id=$(this).attr('data-id');
			log('Using powerup: '+powerups[id].name);
			$('#DXspartacus_pustatus'+id).html('<span title="Firing (sending command to server)">Fire</span>');
			use_powerup(id);
			return false;
		});
	}	
		
	function logit(msg) {
		setTimeout(function() {
			throw new Error(msg);
		}, 0);
	}
	